semantic-release/npm — 303★ on GitHub (JavaScript). :ship: semantic-release plugin to publish a npm package
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Verify the presence of the NPM_TOKEN environment variable, or an .npmrc file, and verify the authentication method is valid.
prepare
Update the package.json version and create the npm package tarball.
addChannel
Add a release to a dist-tag.
publish
Publish the npm package to the registry.
Install
[!TIP]
You do not need to directly depend on this package if you are using semantic-release.
semantic-release already depends on this package, and defining your own direct dependency can result in conflicts when you update semantic-release.
$ npm install @semantic-release/npm -D
Usage
The plugin can be configured in the semantic-release configuration file:
When publishing to the official registry, it is recommended to publish with authentication intended for automation:
For improved security, and since access tokens have recently had their maximum lifetimes restricted,
trusted publishing is recommended when publishing from a supported CI provider
Granular access tokens are recommended when publishing from a CI provider that is not supported by npm for trusted publishing, and can be set via environment variables.
Because these access tokens expire, rotation will need to be accounted for in this scenario.
[!NOTE]
When using trusted publishing, provenance attestations are automatically generated for your packages without requiring provenance to be explicitly enabled.
Trusted publishing from GitHub Actions
To leverage trusted publishing and publish with provenance from GitHub Actions, the id-token: write permission is required to be enabled on the job:
permissions:
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
It's also worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments,
and other features, then more permissions are required to be enabled on this job:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
Refer to the GitHub Actions recipe for npm package provenance for the full CI job's YAML code example.
Trusted publishing for GitLab Pipelines
To leverage trusted publishing and publish with provenance from GitLab Pipelines, NPM_ID_TOKEN needs to be added as an entry under id_tokens in the job definition with an audience of npm:registry.npmjs.org:
See the npm documentation for more details about configuring pipeline details
Trusted publishing for CircleCI
To leverage trusted publishing and publish with provenance from CircleCI, follow the official guide from CircleCI, no additional configuration is required.
Refer to Publish to npm using OIDC trusted publishing - CircleCI Docs for more details.
Unsupported CI providers
Token authentication is required and can be set via environment variables.
Granular access tokens are recommended in this scenario, since trusted publishing is not available from all CI providers.
Because these access tokens expire, rotation will need to be accounted for in your process.
Alternative Registries
Token authentication is required and can be set via environment variables.
See the documentation for your registry for details on how to create a token for automation.
Environment variables
Variable
Description
NPM_TOKEN
Npm token created via npm token create
Options
Options
Description
Default
npmPublish
Whether to publish the npm package to the registry. If false the package.json version will still be updated.
false if the package.json private property is true, true otherwise.
pkgRoot
Directory path to publish.
.
tarballDir
Directory path in which to write the package tarball. If false the tarball is not be kept on the file system.
false
Note: The pkgRoot directory must contain a package.json. The version will be updated only in the package.json and npm-shrinkwrap.json within the pkgRoot directory.
Note: If you use a shareable configuration that defines one of these options you can set it to false in your semantic-release configuration in order to use the default value.
npm configuration
The plugin uses the npm CLI which will read the configuration from .npmrc. See npm config for the option list.
The registry can be configured via the npm environment variable NPM_CONFIG_REGISTRY and will take precedence over the configuration in .npmrc.
The registry, dist-tag, and provenance can be configured under publishConfig in the package.json:
The presence of an .npmrc file will override any specified environment variables.
The presence of registry or dist-tag under publishConfig in the package.json will take precedence over the configuration in .npmrc and NPM_CONFIG_REGISTRY
Examples
The npmPublish and tarballDir option can be used to skip the publishing to the npm registry and instead, release the package tarball with another plugin. For example with the @semantic-release/github plugin:
When publishing from a sub-directory with the pkgRoot option, the package.json and npm-shrinkwrap.json updated with the new version can be moved to another directory with a postversion. For example with the @semantic-release/git plugin:
semantic-release/npm has 303 GitHub stars — refresh the page for the live number, or check github.com/semantic-release/npm. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is semantic-release/npm open source?
Yes — semantic-release/npm ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/semantic-release/npm.
What is semantic-release/npm?
semantic-release/npm (semantic-release/npm) is a JavaScript project on GitHub. From the project's own README: :ship: semantic-release plugin to publish a npm package
Where can I see semantic-release/npm in action?
The project maintains a homepage at https://www.npmjs.com/package/@semantic-release/npm. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about semantic-release/npm?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/semantic-release/npm is the definitive source.
Read full README in the tab above.
Curious whether npm is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about npm.