From ff73eea697d944a9727576b9398d5909a5fee48d Mon Sep 17 00:00:00 2001 From: James Ward Date: Tue, 21 Apr 2026 22:42:40 -0400 Subject: [PATCH] ci: split release from build (#749) --- .github/workflows/publish-release.yml | 104 ++++++++++++++++---------- .github/workflows/release-main.yml | 85 +-------------------- 2 files changed, 66 insertions(+), 123 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 9a93783f2..5519ca14e 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,28 +1,9 @@ -name: Release - Publish Stable Images +name: On Release Published on: - workflow_call: - inputs: - release_tag: - description: 'The release tag to publish (for example v2.2.3)' - required: true - type: string - commit_sha: - description: 'The release commit SHA to package; if omitted, the tag ref is checked out' - required: false - default: '' - type: string - workflow_dispatch: - inputs: - release_tag: - description: 'The existing release tag to publish (for example v2.2.3)' - required: true - type: string - commit_sha: - description: 'Optional release commit SHA override' - required: false - default: '' - type: string + release: + types: + - released jobs: build-and-release: @@ -38,15 +19,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: fetch-depth: 1 - ref: ${{ inputs.commit_sha != '' && inputs.commit_sha || format('refs/tags/{0}', inputs.release_tag) }} - - - name: Record Release Tag and Commit - env: - RELEASE_TAG: ${{ inputs.release_tag }} - run: | - echo "release_tag=${RELEASE_TAG}" >> "$GITHUB_ENV" - echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_ENV" - echo "Stable release tag: ${RELEASE_TAG}" + ref: ${{ github.sha }} - name: Set Up QEMU for Multi-Arch Builds uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 @@ -77,13 +50,13 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | - grimmory/grimmory:${{ env.release_tag }} + grimmory/grimmory:${{ github.event.release.tag_name }} grimmory/grimmory:latest - ghcr.io/grimmory-tools/grimmory:${{ env.release_tag }} + ghcr.io/grimmory-tools/grimmory:${{ github.event.release.tag_name }} ghcr.io/grimmory-tools/grimmory:latest build-args: | - APP_VERSION=${{ env.release_tag }} - APP_REVISION=${{ env.commit_sha }} + APP_VERSION=${{ github.event.release.tag_name }} + APP_REVISION=${{ github.sha }} cache-from: | type=gha,scope=image-shared type=registry,ref=ghcr.io/grimmory-tools/grimmory:buildcache @@ -91,9 +64,60 @@ jobs: type=gha,scope=image-shared,mode=max type=registry,ref=ghcr.io/grimmory-tools/grimmory:buildcache,mode=max - - name: Publish Draft GitHub Release + prepare-release-notification: + name: Prepare Stable Release Notification + needs: + - build-and-release + runs-on: ubuntu-latest + + outputs: + base_tag: ${{ steps.metadata.outputs.base_tag }} + compare_url: ${{ steps.metadata.outputs.compare_url }} + + permissions: + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 0 + ref: ${{ github.event.release.tag_name }} + + - name: Extract Stable Release Metadata + id: metadata env: - GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }} - RELEASE_TAG: ${{ env.release_tag }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_URL: ${{ github.event.release.html_url }} run: | - gh release edit "${RELEASE_TAG}" --draft=false + set -eu + + git fetch origin main --tags --force + BASE_TAG="$(git tag --sort=-version:refname 'v*' | grep -Fxv "$RELEASE_TAG" | head -n 1 || true)" + + COMPARE_URL="${RELEASE_URL}" + if [ -n "$BASE_TAG" ]; then + COMPARE_URL="https://github.com/${GITHUB_REPOSITORY}/compare/${BASE_TAG}...${RELEASE_TAG}" + fi + { + echo "base_tag=${BASE_TAG}" + echo "compare_url=${COMPARE_URL}" + } >> "$GITHUB_OUTPUT" + + notify-discord: + name: Notify Discord Release + needs: + - prepare-release-notification + permissions: {} + uses: ./.github/workflows/notify-discord-release-notes.yml + secrets: + discord_webhook: ${{ secrets.DISCORD_STABLE_WEBHOOK }} + with: + channel: stable + current_version: ${{ github.event.release.tag_name }} + predicted_version: ${{ github.event.release.tag_name }} + details_url: ${{ github.event.release.html_url }} + candidate_sha: ${{ github.sha }} + base_tag: ${{ needs.prepare-release-notification.outputs.base_tag }} + compare_url: ${{ needs.prepare-release-notification.outputs.compare_url }} + mention_text: ${{ vars.DISCORD_STABLE_MENTIONS }} diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index a1ff82144..285124681 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -12,7 +12,6 @@ concurrency: jobs: migration-check: name: Flyway Migration Check - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} uses: ./.github/workflows/migrations-check.yml with: base_ref: ${{ github.event.before }} @@ -21,7 +20,6 @@ jobs: test-suite: name: Test Suite - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} needs: [migration-check] uses: ./.github/workflows/test-suite.yml permissions: @@ -33,7 +31,6 @@ jobs: semantic-release: name: Compute Release, Update Changelog, and Draft GitHub Release - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} needs: [migration-check, test-suite] runs-on: ubuntu-latest @@ -118,88 +115,10 @@ jobs: echo "released=true" >> "$GITHUB_OUTPUT" echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT" - publish-release: - name: Publish Stable Images - if: ${{ needs.semantic-release.outputs.released == 'true' }} - needs: [semantic-release] - uses: ./.github/workflows/publish-release.yml - permissions: - contents: write - packages: write - secrets: inherit - with: - release_tag: ${{ needs.semantic-release.outputs.release_tag }} - commit_sha: ${{ needs.semantic-release.outputs.release_sha }} - - prepare-release-notification: - name: Prepare Stable Release Notification - if: ${{ needs.semantic-release.outputs.released == 'true' && needs.publish-release.result == 'success' }} - needs: [semantic-release, publish-release] - runs-on: ubuntu-latest - - outputs: - base_tag: ${{ steps.metadata.outputs.base_tag }} - compare_url: ${{ steps.metadata.outputs.compare_url }} - release_url: ${{ steps.metadata.outputs.release_url }} - release_version: ${{ steps.metadata.outputs.release_version }} - - permissions: - contents: read - - steps: - - name: Checkout Repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - fetch-depth: 0 - ref: ${{ needs.semantic-release.outputs.release_sha }} - - - name: Extract Stable Release Metadata - id: metadata - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }} - RELEASE_TAG: ${{ needs.semantic-release.outputs.release_tag }} - run: | - set -eu - - git fetch origin main --tags --force - - release_json="$(gh release view "$RELEASE_TAG" --json body,url)" - release_version="${RELEASE_TAG#v}" - base_tag="$(git tag --sort=-version:refname 'v*' | grep -Fxv "$RELEASE_TAG" | head -n 1 || true)" - compare_url="" - release_url="$(printf '%s' "$release_json" | jq -r '.url')" - if [ -n "$base_tag" ]; then - compare_url="https://github.com/${GITHUB_REPOSITORY}/compare/${base_tag}...${RELEASE_TAG}" - fi - { - echo "base_tag=${base_tag}" - echo "compare_url=${compare_url}" - echo "release_url=${release_url}" - echo "release_version=${release_version}" - } >> "$GITHUB_OUTPUT" - - notify-discord: - name: Notify Discord (Stable) - if: ${{ needs.semantic-release.outputs.released == 'true' && needs.publish-release.result == 'success' && needs.prepare-release-notification.result == 'success' }} - needs: [semantic-release, publish-release, prepare-release-notification] - permissions: {} - uses: ./.github/workflows/notify-discord-release-notes.yml - secrets: - discord_webhook: ${{ secrets.DISCORD_STABLE_WEBHOOK != '' && secrets.DISCORD_STABLE_WEBHOOK || secrets.DISCORD_RELEASE_WEBHOOK }} - with: - channel: stable - candidate_sha: ${{ needs.semantic-release.outputs.release_sha }} - base_tag: ${{ needs.prepare-release-notification.outputs.base_tag }} - current_version: ${{ needs.semantic-release.outputs.release_tag }} - details_url: ${{ needs.prepare-release-notification.outputs.release_url }} - compare_url: ${{ needs.prepare-release-notification.outputs.compare_url }} - mention_text: ${{ vars.DISCORD_STABLE_MENTIONS }} - predicted_version: ${{ needs.prepare-release-notification.outputs.release_version }} - backport-release: name: Backport Release Commit to Develop - if: ${{ needs.semantic-release.outputs.released == 'true' && needs.publish-release.result == 'success' }} - needs: [semantic-release, publish-release] + if: ${{ needs.semantic-release.outputs.released == 'true' }} + needs: [semantic-release] runs-on: ubuntu-latest permissions: