Files
Justin Poehnelt 5445a476bb fix(ci): check remote tags in tag-release.sh (#385)
The idempotency guard only checked local tags, but CI checkouts
don't fetch tags. Add git ls-remote fallback so re-runs of the
Release workflow skip already-pushed tags.

Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
2026-03-10 14:03:52 -06:00

18 lines
515 B
Bash
Executable File

#!/usr/bin/env bash
# Creates and pushes a git tag based on the version in package.json.
# Idempotent — skips if the tag already exists.
# Used by changesets/action as the publish command.
set -euo pipefail
VERSION=$(node -p "require('./package.json').version")
TAG="v${VERSION}"
if git rev-parse "$TAG" >/dev/null 2>&1 || git ls-remote --exit-code --tags origin "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
exit 0
fi
echo "Creating tag $TAG"
git tag "$TAG"
git push origin "$TAG"