feat: promote npm edge tag to latest when prerelease is promoted#71
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-phpmyadmin failed. Why did it fail? →
|
| 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 fails on fresh non-prerelease publish
Medium Severity
When a non-prerelease is published directly, GitHub fires both published and released events simultaneously as two separate workflow runs. The promote job (~15 seconds) will almost always finish before the deploy job (install, lint, test, publish — several minutes), causing npm dist-tag add to fail because the version hasn't been published to the registry yet. The PR description claims this is "idempotent" and "harmless," but dist-tag add on a non-existent version is an error, not a no-op — it will produce a consistently failing red workflow run for every fresh non-prerelease publish.
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (b60241fc79)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,12 @@
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)"
+ 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=Skipping promotion::Version $VERSION not yet published to npm, skipping dist-tag operation"
+ 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 when npm dist-tags are updated; main risk is mis-tagging
latestor missing credentials during promotion events.Overview
Updates the release workflow to also trigger on GitHub
releaseevents of typereleased, and adds a lightweightpromotejob that runsnpm dist-tag add ... latestto point npm’slatesttag at the promoted version.The existing
deploypublish pipeline is now explicitly gated to only run onpublishedevents, preventing it from running during promotion events.Written by Cursor Bugbot for commit df58f96. This will update automatically on new commits. Configure here.