Skip to content

Commit b60241f

Browse files
committed
Fix promote job failing on fresh non-prerelease publish
Check if version exists in npm before attempting dist-tag operation. When a non-prerelease is published directly, both 'published' and 'released' events fire simultaneously. The promote job would fail trying to tag a version that hasn't been published yet. Now it skips gracefully if the version doesn't exist.
1 parent df58f96 commit b60241f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ 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+
if npm view "$PACKAGE@$VERSION" version &>/dev/null; then
26+
npm dist-tag add "$PACKAGE@$VERSION" latest
27+
echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)"
28+
else
29+
echo "::notice title=Skipping promotion::Version $VERSION not yet published to npm, skipping dist-tag operation"
30+
fi
2731
env:
2832
TAG_NAME: ${{ github.event.release.tag_name }}
2933
NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}

0 commit comments

Comments
 (0)