Skip to content

Plugin: publisher-npm

Publishes JavaScript and TypeScript packages to the npm registry (or any compatible registry) after semrel has updated package.json. Automatically detects pnpm, Yarn Berry, Yarn Classic, or npm from your lockfiles.

Terminal window
semrel plugin install @semrel/publisher-npm

semrel plugin install downloads the binary to .semrel/plugins/ and updates .semrel.lock. Commit .semrel.lock to pin the version for your team.

Pre-built, signed multi-platform images (linux/amd64, linux/arm64) are published on every release:

Terminal window
docker pull ghcr.io/semrels/publisher-npm:latest

Verify the image signature with cosign:

Terminal window
cosign verify ghcr.io/semrels/publisher-npm:latest \
--certificate-identity-regexp 'https://github.com/SemRels/publisher-npm/.github/workflows/release.yml.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
version: 1
plugins:
- uses: @semrel/updater-npm
phase: pre-tag
args:
update_lockfile: "true"
- uses: @semrel/publisher-npm
phase: release
args:
npm_token: '${env.NPM_TOKEN}'
npm_tag: latest
npm_provenance: "true"
npm_access: public
NameRequiredDefaultDescription
SEMREL_PLUGIN_NPM_TOKENyes (unless dry-run)—npm auth token passed to the package manager as NODE_AUTH_TOKEN.
SEMREL_PLUGIN_NPM_TAGnolatestDist-tag passed as --tag <value>.
SEMREL_PLUGIN_NPM_PROVENANCEnofalseWhen true, appends --provenance to generate npm provenance attestations.
SEMREL_PLUGIN_NPM_ACCESSno—When set to public or restricted, appends --access <value> (useful for scoped packages).
  • SEMREL_VERSION
  • SEMREL_NEXT_VERSION
  • SEMREL_DRY_RUN

publisher-npm inspects the working directory in this order:

  1. pnpm-lock.yaml → pnpm publish
  2. yarn.lock + .yarnrc.yml (or yarn --version >= 2) → yarn npm publish
  3. yarn.lock → yarn publish
  4. Default → npm publish

When SEMREL_DRY_RUN=true, the plugin logs the resolved package name, version, and exact publish command without invoking the registry upload.