Skip to content

Commit

Permalink
refactor: replace Docker publish workflow with CI/CD pipeline and add…
Browse files Browse the repository at this point in the history
… semantic-release configuration
  • Loading branch information
Spikeysanju committed Oct 31, 2024
1 parent d7ecb8b commit fd17647
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 59 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/docker-publish.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI/CD

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
new-release-published: ${{ steps.release.outputs.new-release-published }}
new-release-version: ${{ steps.release.outputs.new-release-version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: release
run: npx semantic-release

build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: release
if: needs.release.outputs.new-release-published == 'true'
steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ needs.release.outputs.new-release-version }}
build-args: |
VERSION=${{ needs.release.outputs.new-release-version }}
cache-from: type=gha
cache-to: type=gha,mode=max
15 changes: 15 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": ["package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM oven/bun

ARG VERSION
ENV APP_VERSION=$VERSION

WORKDIR /app
COPY package.json package.json
RUN bun install
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "3.7"
services:
app:
image: ghcr.io/thisuxhq/blink:latest
build:
context: .
dockerfile: Dockerfile
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"vite": "^5.0.3",
"vitest": "^2.0.4"
"vitest": "^2.0.4",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.2.3",
"semantic-release": "^22.0.7"
},
"dependencies": {
"nanoid": "^5.0.7",
Expand Down

0 comments on commit fd17647

Please sign in to comment.