feat: promote npm edge tag to latest when prerelease is promoted#66
feat: promote npm edge tag to latest when prerelease is promoted#66AaronFeledy merged 1 commit intomainfrom
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-ruby ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| 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.
Promote job races deploy and fails on fresh releases
Medium Severity
When a non-prerelease is published directly, GitHub fires both published and released events as separate workflow runs. The lightweight promote job (~15s) will attempt npm dist-tag add before the deploy job has finished publishing the package to npm. Since the version doesn't exist on the registry yet, the npm dist-tag add command will fail. The PR description assumes this is "harmless" due to idempotency, but dist-tag add on a non-existent version is an error, not a no-op, resulting in a failed workflow run.
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (51cd6abf2c)diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -22,8 +22,14 @@
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}} |




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 npm dist-tags and workflow triggers; main risk is accidentally retagging the wrong version if release metadata/tag parsing is incorrect.
Overview
Updates the release workflow to also trigger on GitHub
releaseevents of typereleased, and adds a lightweightpromotejob that runsnpm dist-tag add ... latestto move a previously prereleased version fromedgeto npmlatest.The existing publish pipeline is now explicitly gated to only run on
publishedevents, avoiding reruns when a prerelease is later promoted.Written by Cursor Bugbot for commit 0f63f2e. This will update automatically on new commits. Configure here.