Skip to content

Commit 31bb6cb

Browse files
authored
fix: retry remote git tag verification in publish-alpha workflow (#88)
- Add retry/poll loop to Verify git tags on remote step (up to 5 min, 10-15s sleep between attempts) matching existing dist-tag retry pattern. - Make Push git tags step idempotent: check remote before pushing, skip existing matching tags, fail on SHA mismatch, create local tag if missing. - Keep npm dist-tag verification, publish step, and server exclusion unchanged.
1 parent b42f1b9 commit 31bb6cb

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

.github/workflows/publish-alpha.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,29 @@ jobs:
7979
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8080

8181
- name: Push git tags
82-
run: git push --tags
82+
run: |
83+
for dir in packages/core packages/dom packages/router packages/testing; do
84+
name=$(node -p "require('./$dir/package.json').name")
85+
version=$(node -p "require('./$dir/package.json').version")
86+
tag="$name@$version"
87+
remote_sha=$(git ls-remote --tags origin "refs/tags/$tag" | awk '{print $1}')
88+
if [ -n "$remote_sha" ]; then
89+
local_sha=$(git rev-list -n 1 "$tag" 2>/dev/null || echo "")
90+
if [ "$remote_sha" = "$local_sha" ]; then
91+
echo "⏭️ git tag $tag already exists at $remote_sha on remote, skipping"
92+
else
93+
echo "::error::git tag $tag exists on remote at $remote_sha but local is $local_sha"
94+
exit 1
95+
fi
96+
else
97+
if ! git rev-parse "$tag" >/dev/null 2>&1; then
98+
git tag "$tag"
99+
echo "Created local tag $tag"
100+
fi
101+
git push origin "$tag"
102+
echo "✅ git tag $tag pushed"
103+
fi
104+
done
83105
84106
- name: Verify alpha dist-tags
85107
run: |
@@ -114,9 +136,22 @@ jobs:
114136
name=$(node -p "require('./$dir/package.json').name")
115137
version=$(node -p "require('./$dir/package.json').version")
116138
tag="$name@$version"
117-
if ! git ls-remote --exit-code --tags origin "refs/tags/$tag" 2>&1; then
118-
echo "::error::git tag $tag not found on remote"
139+
attempt=0
140+
max_attempts=25
141+
while [ $attempt -lt $max_attempts ]; do
142+
attempt=$((attempt + 1))
143+
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
144+
remote_sha=$(git ls-remote --tags origin "refs/tags/$tag" | awk '{print $1}')
145+
echo "✅ $tag found on remote at $remote_sha (attempt $attempt)"
146+
break
147+
fi
148+
echo "Attempt $attempt: $tag not yet found on remote"
149+
if [ $attempt -lt $max_attempts ]; then
150+
sleep $((RANDOM % 6 + 10))
151+
fi
152+
done
153+
if ! git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
154+
echo "::error::git tag $tag not found on remote (after $max_attempts attempts)"
119155
exit 1
120156
fi
121-
echo "✅ git tag $tag found on remote"
122157
done

0 commit comments

Comments
 (0)