Repository navigation
ci: switch release workflow to npm Trusted Publishing - #9
Merged
Merged
Conversation
- Bump runner to Node 20 (npm 10 required for OIDC and --provenance). - Add id-token: write permission so the workflow can request an OIDC token. - Drop NODE_AUTH_TOKEN; npm publish authenticates via Trusted Publishing. - Add --provenance --access public to the publish step. - Add workflow_dispatch with a force_publish input to re-publish a version without re-tagging (needed to recover from a failed publish like v2.3.0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The v2.3.0 release failed at
npm publishbecause the long-livedNPM_TOKENis no longer valid. npm now recommends Trusted Publishing (OIDC) for CI/CD, which removes the need for any long-lived token.The tag
v2.3.0and the GitHub Release for v2.3.0 were already created in the original release run, so this PR keeps them intact and only fixes the publish path.Changes
release.yml;ci.ymlkeeps Node 16 since it doesn't publish). npm 10 is required for OIDC and--provenance.permissions: id-token: writeadded so the workflow can request the OIDC token from GitHub.NODE_AUTH_TOKENremoved;npm publishnow uses Trusted Publishing.--provenance --access publicadded to the publish command.workflow_dispatchtrigger with aforce_publishboolean input. Whenforce_publish=true, install/lint/test/build/publish run even if the tag already exists; tag and GitHub Release creation steps still only run when the tag does not exist. This is the recovery path for v2.3.0 and for any similar failure in the future.Recovery plan
develop.develop→main, merge it. The push tomainwill run the workflow, seev2.3.0tag already exists, and skip everything (baseline run of the new workflow).gh workflow run release.yml -f force_publish=true(or via the Actions UI). Withforce_publish=true, the workflow will install/build andnpm publishv2.3.0 to npm with provenance.npm view undisclosed@2.3.0 versionreturns2.3.0.Test plan
ci.ymlstill on Node 16).main, the automatic push-trigger run skips publish (tag exists, noforce_publish).force_publish=truepublishes v2.3.0 to npm successfully with provenance.