From 51cd6abf2c67b7a7e5bd24c910687007bf440543 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 20 Feb 2026 04:02:32 +0000 Subject: [PATCH] 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. --- .github/workflows/release.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfe2b88..815b7a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,8 +22,14 @@ jobs: run: | VERSION=$(echo "$TAG_NAME" | sed 's/^v//') PACKAGE=$(node -p "require('./package.json').name") - npm dist-tag add "$PACKAGE@$VERSION" latest - echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)" + + # Check if this version exists on npm (i.e., it's a promotion of an existing prerelease) + if npm view "$PACKAGE@$VERSION" version &>/dev/null; then + npm dist-tag add "$PACKAGE@$VERSION" latest + echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)" + else + echo "::notice title=Skipped promotion::Version $VERSION does not exist on npm yet (fresh release, not a promotion)" + fi env: TAG_NAME: ${{ github.event.release.tag_name }} NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}