Skip to content

Commit 51cd6ab

Browse files
committed
Fix race condition in promote job by checking version exists on npm
The promote job now checks if the package version exists on npm before attempting to add the dist-tag. This prevents failures when a fresh non-prerelease is published, which triggers both 'published' and 'released' events simultaneously. The lightweight promote job would previously race the deploy job and fail when trying to tag a not-yet-published version.
1 parent 0f63f2e commit 51cd6ab

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ jobs:
2222
run: |
2323
VERSION=$(echo "$TAG_NAME" | sed 's/^v//')
2424
PACKAGE=$(node -p "require('./package.json').name")
25-
npm dist-tag add "$PACKAGE@$VERSION" latest
26-
echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)"
25+
26+
# Check if this version exists on npm (i.e., it's a promotion of an existing prerelease)
27+
if npm view "$PACKAGE@$VERSION" version &>/dev/null; then
28+
npm dist-tag add "$PACKAGE@$VERSION" latest
29+
echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)"
30+
else
31+
echo "::notice title=Skipped promotion::Version $VERSION does not exist on npm yet (fresh release, not a promotion)"
32+
fi
2733
env:
2834
TAG_NAME: ${{ github.event.release.tag_name }}
2935
NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}

0 commit comments

Comments
 (0)