From 6ce311b866d2756cc2eeae814f12b7d6c8221f81 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 10 Oct 2026 03:51:48 +0000 Subject: [PATCH] ci(release): skip the tag-push run when the release already exists Publishing a release on GitHub creates its tag, which also fires the push trigger. That run queued behind the release run and would rebuild and re-upload the assets. It now stops once it sees the release exists. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EtxtFPs6UBAWXqEpkj2W2N --- .github/workflows/release.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 304588a..43fd0d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,9 @@ on: types: [published] # Pushing a v* tag also releases: the job creates the GitHub release from the # CHANGELOG section first. A release created with GITHUB_TOKEN doesn't fire - # `release: published`, so this never runs twice for one tag. + # `release: published`. Publishing a release on GitHub also pushes its tag; + # that push run queues behind the release run and then stops, because the + # release already exists. push: tags: ['v*'] @@ -22,13 +24,15 @@ jobs: - uses: actions/checkout@v4 - name: Create GitHub release for a pushed tag + id: release if: github.event_name == 'push' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | TAG="${GITHUB_REF_NAME}" if gh release view "${TAG}" > /dev/null 2>&1; then - echo "Release ${TAG} already exists" + echo "Release ${TAG} already exists; its own run publishes it" + echo "skip=true" >> "$GITHUB_OUTPUT" exit 0 fi # Release notes are the CHANGELOG section for this version. @@ -43,6 +47,7 @@ jobs: gh release create "${TAG}" --verify-tag --title "${TAG}" --notes-file release-notes.md - name: Build release binary + if: steps.release.outputs.skip != 'true' run: | swift build -c release --disable-sandbox cp .build/release/XCForgeCLI .build/release/xcforge @@ -50,6 +55,7 @@ jobs: echo "BINARY_PATH=.build/release/xcforge" >> "$GITHUB_ENV" - name: Package tarball (binary + xcforgeWDA) + if: steps.release.outputs.skip != 'true' run: | BINARY="${BINARY_PATH}" VERSION="${GITHUB_REF_NAME}" @@ -62,6 +68,7 @@ jobs: echo "SHA256=$(shasum -a 256 "${TARBALL}" | awk '{print $1}')" >> "$GITHUB_ENV" - name: Package mcpb bundle + if: steps.release.outputs.skip != 'true' run: | BINARY="${BINARY_PATH}" VERSION="${GITHUB_REF_NAME}" @@ -72,6 +79,7 @@ jobs: echo "MCPB_SHA=${MCPB_SHA}" >> "$GITHUB_ENV" - name: Update server.json + if: steps.release.outputs.skip != 'true' run: | VERSION="${GITHUB_REF_NAME}" DOWNLOAD_URL="https://github.com/justinthevoid/xcforge/releases/download/${VERSION}/xcforge-${VERSION}.mcpb" @@ -85,11 +93,13 @@ jobs: server.json > server.json.tmp && mv server.json.tmp server.json - name: Upload release assets + if: steps.release.outputs.skip != 'true' run: gh release upload --clobber "${GITHUB_REF_NAME}" "${TARBALL}" "${MCPB}" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Commit updated server.json + if: steps.release.outputs.skip != 'true' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" @@ -109,6 +119,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update Homebrew tap + if: steps.release.outputs.skip != 'true' env: HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} run: |