This project uses npm Trusted Publishing (OIDC) via GitHub Actions. When a GitHub release is created, the npm-publish workflow automatically builds and publishes the package to npm — no long-lived tokens required.
You must have published at least one version of the package to npm before you can enable trusted publishing.
- Go to npmjs.com and sign in to the account that owns your package.
- Navigate to your package settings page:
https://www.npmjs.com/package/<your-package-name>/access - Under Publishing access, find the Trusted Publishers section.
- Click Add a trusted publisher and fill in:
- Organization or user: Your GitHub username or organization
- Repository: Your repository name
- Workflow filename:
npm-publish.yml - Environment: (leave blank)
- Save the configuration.
Once this is done, the GitHub Actions workflow can publish to npm using OIDC without any stored secrets (NPM_TOKEN is no longer needed and can be removed from the repository secrets if it exists).
-
Update the version in
package.json:# Bump the patch version (e.g., 0.10.2 → 0.10.3) npm version patch # Or for a minor version bump (e.g., 0.10.2 → 0.11.0) npm version minor # Or for a major version bump (e.g., 0.10.2 → 1.0.0) npm version major
This updates
package.jsonand creates a git tag automatically. -
Push the commit and tag to GitHub:
git push origin master --follow-tags
-
Create a GitHub release from the tag:
- Go to your repository's releases page and click Draft a new release
- Select the tag you just pushed (e.g.,
v0.10.3or0.10.3) - Fill in the release title and notes
- Click Publish release
-
The npm-publish workflow will trigger automatically, build the package, and publish it to npm with provenance attached.
checkout → install pnpm → setup node → pnpm install → pnpm build → npm publish --provenance
- Uses OIDC (
id-token: writepermission) so npm can verify the package was published from this repository. - Runs
pnpm install --frozen-lockfilefor reproducible builds. - Publishes with
--provenanceso consumers can verify the package origin on npmjs.com.
| Problem | Fix |
|---|---|
| "No matching trusted publisher" error in CI | Ensure the workflow filename in npmjs.com settings matches exactly: npm-publish.yml |
| 403 Forbidden during publish | Verify that trusted publishing is configured for the correct user/org and repo on npmjs.com |
| Version already exists | You need to bump the version in package.json before publishing. npm does not allow re-publishing the same version. |
| Provenance error | Make sure the workflow has permissions: id-token: write and is running in a public repository |