Repository navigation
ci: publish to npm from changesets with trusted publishing - #6
Merged
Merged
Conversation
A release workflow built from changesets/action v2's sub-actions: with changesets on main it opens a "Version Packages" pull request; once that is merged, it packs the packages without credentials and publishes the tarballs in a separate job, the only one allowed to mint an OIDC token for npm trusted publishing. No npm token is stored anywhere. Needs two settings before it can work: the trusted publisher on the package's npmjs.com page (this repository, workflow release.yml), and "Allow GitHub Actions to create and approve pull requests" in the repository's Actions settings.
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.
Publishes to npm from changesets, without an npm token.
How it works
.github/workflows/release.yml, built from changesets/action v2's sub-actions (their recommended layout for trusted publishing):contentsandpull-requests: write).id-token: write. It installs with--ignore-scripts, builds nothing, and publishes the packed tarballs through npm trusted publishing, then tags and creates GitHub releases.Actions are pinned by SHA like the compat workflow. pnpm handles the OIDC exchange from 11.1.3 on (the fix for an
.npmrcwritten by setup-node); the repo pins 11.15.1, and the publish job prints the pnpm and npm versions.Before it can publish
On https://www.npmjs.com/package/@eisbachcode/emdash-plugin-analytics → Settings → Trusted publishing, add a GitHub Actions publisher:
eisbachcodeemdash-pluginsrelease.ymlThe repository already allows GitHub Actions to create pull requests.
Merging this runs the workflow once: there are no changesets and 0.1.0 is already on npm, so it selects "none" and does nothing.
No changeset: CI only.