From 604e0ba089a766b9ba75fa5748cc1a24ef0f76fb Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Sun, 22 Feb 2026 14:55:49 -0600 Subject: [PATCH] fix: handle race condition in release promote job When a fresh non-prerelease is published, GitHub fires both 'published' and 'released' events simultaneously. The promote job races the deploy job and fails because the package isn't on npm yet. Add a retry loop (up to 5 min) so promote waits for the package to appear, while still failing loudly if it never does. --- .github/workflows/release.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38a2081..42671a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,8 +22,20 @@ 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)" + + # Wait for version to be available on npm (handles race with deploy job) + for i in $(seq 1 30); do + 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" + exit 0 + fi + echo "Waiting for $PACKAGE@$VERSION on npm... (attempt $i/30)" + sleep 10 + done + + echo "::error title=Promotion failed::$PACKAGE@$VERSION not found on npm after 5 minutes" + exit 1 env: TAG_NAME: ${{ github.event.release.tag_name }} NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}