Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,32 @@ on:
release:
types:
- published

- released
jobs:
# When a prerelease is promoted to a full release, update the npm latest tag
promote:
if: github.event.action == 'released'
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install node 20
uses: actions/setup-node@v6
with:
node-version: '20'
registry-url: https://registry.npmjs.org
- name: Promote edge to latest
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)"
env:
TAG_NAME: ${{ github.event.release.tag_name }}
NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Race condition: promote fails before deploy publishes package

Medium Severity

When a fresh non-prerelease is published, GitHub fires both published and released events as separate workflow runs. The promote job (~15s) will finish well before deploy (minutes of install, lint, test, publish). The npm dist-tag add command in promote will fail because the version hasn't been published to npm yet by deploy. The PR description claims this is "harmless" but it will produce a failed workflow run. Adding needs: deploy wouldn't help since they're in separate workflow runs. The promote job's if condition could also check github.event.release.prerelease == true to only run for actual prerelease promotions.

Additional Locations (1)

Fix in Cursor Fix in Web


deploy:
if: github.event.action == 'published'
runs-on: ${{ matrix.os }}
env:
TERM: xterm
Expand Down
Loading