feat: promote npm edge tag to latest when prerelease is promoted - #48
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-mssql 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 across jobs in same workflow
Low Severity
The new promote job uses actions/checkout@v6 and actions/setup-node@v6, while the deploy job in the same file and every other workflow in the repo consistently uses @v4. Mixing major versions within the same workflow file is surprising and increases maintenance burden. checkout@v6 also introduced credential-handling changes with known compatibility caveats, and setup-node@v6 enables npm caching by default (unnecessary here since no npm install runs).
| 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: promote job runs before deploy publishes
Medium Severity
When a fresh non-prerelease is published, both published and released events can fire, creating two independent workflow runs. The promote job (~20s total) will attempt npm dist-tag add long before the deploy job (~2+ minutes) reaches its npm publish step. Since the version doesn't exist on npm yet, the npm dist-tag add command will fail. The PR description states this scenario is "harmless," but dist-tag add can only be idempotent if the version already exists on npm. The result is a failed workflow run on every non-prerelease publish that triggers both events.


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
Workflow-only change that adjusts GitHub Actions triggers and npm dist-tagging; main risk is mis-tagging
lateston release promotion.Overview
Updates the NPM release workflow to also trigger on GitHub
releaseevents of typereleased(in addition topublished).Adds a new
promotejob that runs only onreleasedto move the package version referenced by the release tag fromedgeto the npmlatestdist-tag vianpm dist-tag add, and gates the existingdeployjob to run only onpublishedevents.Written by Cursor Bugbot for commit ef99a85. This will update automatically on new commits. Configure here.