From 5609864d389d353f3e2cd011414391c825e04539 Mon Sep 17 00:00:00 2001 From: RY4N Date: Fri, 27 Mar 2026 01:26:57 +0600 Subject: [PATCH] feat: migrate to CoorenLabs-style dual-workflow (release-triggered docker build) --- .github/workflows/package.yml | 57 ++++++----------------------------- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 7cb7f4e..c5f7f79 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -14,6 +14,8 @@ on: branches: - master - main + release: + types: [published] workflow_dispatch: concurrency: @@ -29,6 +31,7 @@ jobs: quality-checks: name: Code Quality & Security runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout repository uses: actions/checkout@v4 @@ -71,6 +74,7 @@ jobs: name: Build & Test runs-on: ubuntu-latest needs: quality-checks + if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout repository uses: actions/checkout@v4 @@ -101,8 +105,7 @@ jobs: publish-docker: name: Build & Push Docker Image runs-on: ubuntu-latest - needs: [quality-checks, build-test] - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.event_name == 'release' permissions: contents: read packages: write @@ -123,22 +126,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Get version from package.json - id: pkg_version - run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - - - name: Lowercase image name - id: image_name_step - run: echo "IMAGE_NAME_LOWER=$(echo ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT - - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: - images: ${{ steps.image_name_step.outputs.IMAGE_NAME_LOWER }} + images: ghcr.io/${{ github.repository }} tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,format=long type=raw,value=latest - type=semver,pattern={{version}},value=v${{ steps.pkg_version.outputs.VERSION }} - name: Build and push Docker image uses: docker/build-push-action@v5 @@ -151,40 +148,4 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - create-release: - name: Create GitHub Release - runs-on: ubuntu-latest - needs: publish-docker - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - permissions: - contents: write - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Get version from package.json - id: get_version - run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - - - name: Check if tag exists - id: check_tag - run: | - if git rev-parse "v${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then - echo "EXISTS=true" >> $GITHUB_OUTPUT - else - echo "EXISTS=false" >> $GITHUB_OUTPUT - fi - - - name: Create Release - if: steps.check_tag.outputs.EXISTS == 'false' - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ steps.get_version.outputs.VERSION }} - name: v${{ steps.get_version.outputs.VERSION }} - generate_release_notes: true - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..36e6672 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Automated Build and Release + +on: + push: + branches: + - master + - main + paths-ignore: + - '**.md' + - '.gitignore' + +jobs: + release: + name: Tag and Release + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: GitHub Tag Action + id: tag_action + uses: anothrNick/github-tag-action@1.71.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: true + DEFAULT_BUMP: patch + + - name: Create GitHub Release + if: steps.tag_action.outputs.new_tag != '' + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag_action.outputs.new_tag }} + name: Release ${{ steps.tag_action.outputs.new_tag }} + body: | + Automated release for version ${{ steps.tag_action.outputs.new_tag }} + + Changes in this version: + ${{ github.event.head_commit.message }} + generate_release_notes: true + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}