From 1741e62b7ee9922efee6c359dc38c676cc14a15a Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Sat, 10 Oct 2026 17:56:16 +0100 Subject: [PATCH] fix: let a re-run of the publish job reuse the release tag The tag step failed on the second attempt because the first had already pushed the tag. It now accepts an existing tag that names the merged commit and still fails for any other. --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e3a177..633c310 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,8 +148,15 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git tag "v${{ steps.version.outputs.version }}" - git push origin "v${{ steps.version.outputs.version }}" + tag="v${{ steps.version.outputs.version }}" + # A re-run after a failed publish step finds the tag from the first attempt; it must name this commit, and is then left alone. + if git ls-remote --exit-code --tags origin "refs/tags/${tag}" > /dev/null; then + git fetch --quiet origin "refs/tags/${tag}:refs/tags/${tag}" + test "$(git rev-parse "${tag}^{commit}")" = "$(git rev-parse HEAD)" + else + git tag "${tag}" + git push origin "${tag}" + fi - name: Upgrade npm for OIDC trusted publishing (needs npm CLI >=11.5.1) run: npm install -g npm@latest - run: pnpm publish --access public --no-git-checks