Skip to content

Commit 30800cd

Browse files
mariotoffiaclaude
andcommitted
ci: idempotent tag step — check remote, not local clone
actions/checkout@v4 does not fetch tags by default, so the previous `git rev-parse "$RELEASE_VERSION"` always missed and the step then failed at `git push origin <tag>` with "(already exists)" whenever a non-bumping commit landed on master (docs change, README tweak, workflow tweak, etc). Check the remote directly with `git ls-remote --exit-code --tags`. The non-zero exit selects the push branch; zero exit (tag present) skips the tag operation. The release pipeline is now idempotent across multiple pushes at the same version. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1db32a0 commit 30800cd

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,15 @@ jobs:
143143
RELEASE_VERSION: ${{ steps.version.outputs.version }}
144144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145145
run: |
146-
echo "Creating Git tag for version: $RELEASE_VERSION"
147-
git config --global user.name "GitHub Actions"
148-
git config --global user.email "actions@github.com"
149-
if git rev-parse "$RELEASE_VERSION" >/dev/null 2>&1; then
150-
echo "Tag $RELEASE_VERSION already exists, skipping"
146+
# actions/checkout@v4 does not fetch tags, so check the remote
147+
# directly. `--exit-code` makes ls-remote return non-zero when no
148+
# matching ref exists, which we use to decide whether to push.
149+
if git ls-remote --exit-code --tags origin "refs/tags/$RELEASE_VERSION" >/dev/null 2>&1; then
150+
echo "Tag $RELEASE_VERSION already exists on remote, skipping"
151151
else
152+
echo "Creating Git tag for version: $RELEASE_VERSION"
153+
git config --global user.name "GitHub Actions"
154+
git config --global user.email "actions@github.com"
152155
git tag "$RELEASE_VERSION"
153156
git push origin "$RELEASE_VERSION"
154157
fi

0 commit comments

Comments
 (0)