ci: publish releases with npm trusted publishing - #785
Merged
Conversation
Move releases off the local machine and into GitHub Actions. The new Release workflow is dispatched manually with a bump type and dist-tag, then bumps the version, tags it, builds, publishes to npm over OIDC and creates the GitHub release. No npm token is needed anywhere, and packages get provenance for free. The local `release` scripts are removed so nobody publishes from a laptop by accident, along with the dead semantic-release config block that no longer matched how releases were cut.
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
`main` is protected and the repository is user-owned, so the GitHub Actions app cannot be added as a ruleset bypass actor. Mint a short-lived token from a dedicated GitHub App instead, and use it for the checkout so bumpp can push the version commit and tag. GITHUB_TOKEN drops to contents: read, since everything that writes now goes through the app token.
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.
Moves releases off my local machine and into GitHub Actions, using npm trusted publishing. The trusted publisher is already configured on npm and bound to
release.yml.How a release works now
Actions tab > Release > Run workflow, on the branch to release:
version- the bump:patch,minor,major, or apre*variant.tag- the npm dist-tag,latestby default. Usebetafor prereleases.The workflow then bumps the version with
bumpp, commits and tagsvX.Y.Z, pushes, builds, publishes to npm, and creates a GitHub release with generated notes (marked prerelease forpre*bumps).What changed
.github/workflows/release.yml- new manually dispatched release workflow.id-token: writelets npm authenticate over OIDC, so there is noNODE_AUTH_TOKENand no npm secret in the repo. Provenance is attested automatically.contents: writecovers the version commit/tag push and the GitHub release.attw/publint/size-limitchecks throughpostbuild.releasescripts from the package and the root passthrough. With trusted publishing configured, a localnpm publishis rejected anyway, so dropping them avoids a confusing failure."release"semantic-release config block from the package manifest. No semantic-release dependency was installed and releases were not cut that way.