From c18a5933c29ec0dc5486926a7bfa08d04be7bf33 Mon Sep 17 00:00:00 2001 From: SamTV12345 Date: Mon, 23 Nov 2026 19:57:58 +0100 Subject: [PATCH 1/2] ci(release): keep an existing tag instead of failing Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu --- .github/workflows/publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 22b1bd9..96d09c1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -68,5 +68,10 @@ jobs: git commit -m "release: v${{ inputs.version }}" git push origin HEAD:main fi - git tag "v${{ inputs.version }}" - git push origin "v${{ inputs.version }}" + # A tag created beforehand (e.g. with a GitHub release) is kept. + if git rev-parse -q --verify "refs/tags/v${{ inputs.version }}" >/dev/null; then + echo "Tag v${{ inputs.version }} already exists, not re-tagging" + else + git tag "v${{ inputs.version }}" + git push origin "v${{ inputs.version }}" + fi From 0dce20de1ee8f683cfe7cbd786d4271a6f5b6b74 Mon Sep 17 00:00:00 2001 From: SamTV12345 Date: Mon, 23 Nov 2026 20:14:04 +0100 Subject: [PATCH 2/2] ci(release): only accept an existing tag that points at the released source Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu --- .github/workflows/publish.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 96d09c1..a0c6760 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,6 +33,22 @@ jobs: - run: pnpm install --frozen-lockfile + # A tag created beforehand (e.g. with a GitHub release) is only accepted + # if it points at the source being released; otherwise stop before + # anything is published. + - name: Check existing tag + run: | + TAG="v${{ inputs.version }}" + if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then + TAGGED=$(git rev-parse "$TAG^{commit}") + HEAD_SHA=$(git rev-parse HEAD) + if [ "$TAGGED" != "$HEAD_SHA" ]; then + echo "::error::Tag $TAG points at $TAGGED, but main is at $HEAD_SHA. Delete or move the tag, then run the release again." + exit 1 + fi + echo "Tag $TAG already points at main ($HEAD_SHA); it is kept." + fi + - name: Set version run: | npm pkg set version="${{ inputs.version }}" @@ -68,7 +84,8 @@ jobs: git commit -m "release: v${{ inputs.version }}" git push origin HEAD:main fi - # A tag created beforehand (e.g. with a GitHub release) is kept. + # Checked above: an existing tag points at the released source + # (main before the version bump). if git rev-parse -q --verify "refs/tags/v${{ inputs.version }}" >/dev/null; then echo "Tag v${{ inputs.version }} already exists, not re-tagging" else