feat: promote npm edge tag to latest when prerelease is promoted - #43
Conversation
Adds a 'released' trigger to the release workflow with a lightweight 'promote' job that runs npm dist-tag to move 'latest' to the current version when a prerelease is promoted to a full release. The existing publish pipeline remains gated to 'published' events only.
❌ Deploy Preview for lando-mailpit failed. Why did it fail? →
|
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| - name: Install node 20 | ||
| uses: actions/setup-node@v6 |
There was a problem hiding this comment.
Inconsistent action versions between workflow jobs
Low Severity
The new promote job uses actions/checkout@v6 and actions/setup-node@v6, while the existing deploy job in the same workflow uses @v4 for both. Having two different major versions of the same actions in one workflow file creates a maintenance inconsistency and can confuse future contributors about which version is canonical. Since setup-node v6 has breaking changes (removed always-auth, changed caching defaults), the version split makes it harder to reason about behavior across jobs.
Additional Locations (1)
| 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}} |
There was a problem hiding this comment.
Race condition causes promote job to fail on non-prerelease publishes
Medium Severity
When a fresh non-prerelease is published, both published and released events fire, creating two separate concurrent workflow runs. The promote job (~15 seconds) completes long before the deploy job (~3+ minutes) reaches npm publish. Since npm dist-tag add fails with a 404 when the version doesn't exist on the registry yet, the promote job will error out on every fresh non-prerelease publish. The PR description claims this scenario is "harmless" and "idempotent," but the job actually fails. While functionally the deploy job still publishes to latest correctly, the persistent red X creates noise and can desensitize maintainers to real promote failures.


Problem
When a release is published as a prerelease, it gets tagged as
edgeon npm. Later, when the release is promoted to a full release in GitHub, the npmlatesttag doesn't update because the workflow only triggered onpublished.Solution
releasedto the release workflow trigger typespromotejob that only runsnpm dist-tag add latest— no install, no lint, no tests, no re-publishreleasedevent (when a prerelease is promoted to full release)deployjob is now explicitly gated topublishedevents only (no behavior change)TAG_NAMEenv var instead of direct interpolation to prevent script injectionFlow
edgetag (unchanged)promotejob runs, pointslatestto that version (~15s)The
dist-tag addcommand is idempotent, so if bothpublishedandreleasedfire on a fresh non-prerelease publish, the redundant promote is harmless.Note
Low Risk
CI-only change that adjusts GitHub Actions triggers and npm dist-tagging; main risk is accidentally retagging the wrong version if release tags are misconfigured.
Overview
Updates the release GitHub Action to also trigger on
release.releasedevents (in addition topublished).Adds a lightweight
promotejob that runs only onreleasedto retag the package version from the GitHub release tag as npmlatestvianpm dist-tag add, and gates the existingdeploypublish pipeline to run only onpublished.Written by Cursor Bugbot for commit 2ab3551. This will update automatically on new commits. Configure here.