Skip to content

Commit 1cfae98

Browse files
Copilotrajbos
andcommitted
fix: improve tag validation and verification reliability
- Use git ls-remote --exit-code for more reliable tag checking - Add verification loop to ensure tag is available on remote - Prevents race conditions in release creation - Provides better error handling with retry logic Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
1 parent 2c31140 commit 1cfae98

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959
VERSION="v${{ steps.package_version.outputs.package_version }}"
6060
echo "Creating tag: $VERSION"
6161
62-
# Check if tag already exists on remote
63-
if git ls-remote --tags origin | grep -q "refs/tags/$VERSION$"; then
62+
# Check if tag already exists on remote using exit code
63+
if git ls-remote --exit-code --tags origin "refs/tags/$VERSION" >/dev/null 2>&1; then
6464
echo "❌ Tag $VERSION already exists on remote!"
6565
echo "Please update the version in package.json or delete the existing tag."
6666
exit 1
@@ -71,7 +71,20 @@ jobs:
7171
git config user.email "github-actions[bot]@users.noreply.github.com"
7272
git tag -a "$VERSION" -m "Release $VERSION"
7373
git push origin "$VERSION"
74-
echo "✅ Tag $VERSION created and pushed"
74+
75+
# Verify tag was created successfully on remote
76+
echo "Verifying tag was created on remote..."
77+
for i in {1..5}; do
78+
if git ls-remote --exit-code --tags origin "refs/tags/$VERSION" >/dev/null 2>&1; then
79+
echo "✅ Tag $VERSION created and verified on remote"
80+
exit 0
81+
fi
82+
echo "Waiting for tag to propagate (attempt $i/5)..."
83+
sleep 2
84+
done
85+
86+
echo "❌ Failed to verify tag creation on remote"
87+
exit 1
7588
7689
- name: Extract version from tag
7790
id: extract_version

0 commit comments

Comments
 (0)