12.0.1 • Published 8 months ago

@semantic-release/npm v12.0.1

Weekly downloads
396,212
License
MIT
Repository
github
Last release
8 months ago

@semantic-release/npm

semantic-release plugin to publish a npm package.

Build Status npm latest version npm next version npm beta version

StepDescription
verifyConditionsVerify the presence of the NPM_TOKEN environment variable, or an .npmrc file, and verify the authentication method is valid.
prepareUpdate the package.json version and create the npm package tarball.
addChannelAdd a release to a dist-tag.
publishPublish the npm package to the registry.

Install

$ npm install @semantic-release/npm -D

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": ["@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/npm"]
}

Configuration

npm registry authentication

The npm token authentication configuration is required and can be set via environment variables.

Automation tokens are recommended since they can be used for an automated workflow, even when your account is configured to use the auth-and-writes level of 2FA.

npm provenance

If you are publishing to the official registry and your pipeline is on a provider that is supported by npm for provenance, npm can be configured to publish with provenance.

Since semantic-release wraps the npm publish command, configuring provenance is not exposed directly. Instead, provenance can be configured through the other configuration options exposed by npm. Provenance applies specifically to publishing, so our recommendation is to configure under publishConfig within the package.json.

npm provenance on GitHub Actions

For package provenance to be signed on the GitHub Actions CI the following permission is required to be enabled on the job:

permissions:
  id-token: write # to enable use of OIDC for npm provenance

It's 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 npm provenance

Refer to the GitHub Actions recipe for npm package provenance for the full CI job's YAML code example.

Environment variables

VariableDescription
NPM_TOKENNpm token created via npm token create

Options

OptionsDescriptionDefault
npmPublishWhether 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.
pkgRootDirectory path to publish..
tarballDirDirectory 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 and dist-tag can be configured under publishConfig in the package.json:

{
  "publishConfig": {
    "registry": "https://registry.npmjs.org/",
    "tag": "latest"
  }
}

Notes:

  • 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:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/npm",
      {
        "npmPublish": false,
        "tarballDir": "dist"
      }
    ],
    [
      "@semantic-release/github",
      {
        "assets": "dist/*.tgz"
      }
    ]
  ]
}

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:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/npm",
      {
        "pkgRoot": "dist"
      }
    ],
    [
      "@semantic-release/git",
      {
        "assets": ["package.json", "npm-shrinkwrap.json"]
      }
    ]
  ]
}
{
  "scripts": {
    "postversion": "cp -r package.json .. && cp -r npm-shrinkwrap.json .."
  }
}
trippkit@html-validate/semantic-release@droplt/core@ahmadnassri/semantic-release-configcta-blocksemantic-realise-demo@test-babu-library/aifian-babu@test-aifian-library/aifian_storybook_babu@educationperfect/semantic-release@ahmadnassri/semantic-release@coobeet/semantic-release-configtest-semantic-release-yakovlevyuri-2@wishlez/semantic-releasesenn-node-linter@araclx/semantic-release@infinitebrahmanuniverse/nolb-_sema@adfinis-sygroup/semantic-release-configjob-web-appdh-test-cafe-automation-library@everything-registry/sub-chunk-818@peakfijn/config-release-expo@peakfijn/config-release-laravel@peakfijn/expo-semantic-release@healform/liquideyecue-frontend-utilitiessvelte-credit-cardsvue-material-3webapp-forkedshader-artshared-node-library-devsan-ssrsem-playsemantic-release-squashsemantic-release-squash3semantic-release-tsheets-testsemantic-release-versioning-testsemantic-release-wo-notessemantic-release-ramkraosemantic-release-preconfigured-conventional-commitsscratch-semantic-release-configscreepers-steamless-clientrhys.hoadrelease-config-hamrahtelstarwars-names-kshzhtemp-semantic-release-debugtemp-test-semantic-releasetemplate-typescript-npm-clisemantic-release-github-configsemantic-release-config-aristeksemantic-release-config-fabulatorsemantic-release-config-xeroxsemantic-release-expo-npm-github-publishsemantic-release-configsemantic-releasesemantic-release-flexsemantic-release-node-prepsemantic-release-npm-configsemantic-release-npm-deprecatesemantic-release-npm-githubsemantic-release-npm-multiple-scopedsemantic-release-gitlab-publishsemantic-release-monorepo-configsemantic-release-plussemantic-release-jira-listertest-release-actionteste-semantic-releasevalues-coverage@joshunrau/semantic-release-config@koyfin/message-busgrooveshop-media-streamjava-projectist-user-experienceinteg-scriptsinnostark-design-systemmqtt-nextmonyo-semantic-releasehmd2v-fork-xhd-wallet-apiiffe-commitkeycloak-nest-corehomebridge-cisco-collaboration-deviceslaux-compilergh-projects-working-time-reportergh-release-test-actiongh-cookiegithub-workflow-managerglobal-swapmonorepo-semantic-releasencrtlieberman_gamemygitactioncourselvbyte-cdnmaxweldsouza-test-reponodejs-env-checkeropen-sauced-semantic-config-testpref-image-uploaderpsivasemantic-releasepixt_auth_servicepixtuserserviceplaybook-media-typescript-sdknpmzuluomniboard
12.0.1

8 months ago

12.0.0

9 months ago

11.0.3

10 months ago

11.0.2

1 year ago

10.0.5

1 year ago

10.0.6

1 year ago

11.0.0

1 year ago

11.0.1

1 year ago

10.0.4

2 years ago

10.0.0

2 years ago

10.0.1

2 years ago

10.0.2

2 years ago

10.0.3

2 years ago

10.0.0-beta.4

2 years ago

9.0.2

2 years ago

10.0.0-beta.2

2 years ago

10.0.0-beta.3

2 years ago

10.0.0-beta.1

2 years ago

9.0.1

3 years ago

8.0.4-beta.1

3 years ago

9.0.0-beta.3

3 years ago

9.0.0-beta.2

3 years ago

9.0.0-beta.1

3 years ago

9.0.0

3 years ago

8.0.3

3 years ago

8.0.1

3 years ago

8.0.2

3 years ago

8.0.0

3 years ago

8.0.0-beta.1

3 years ago

7.1.3

4 years ago

7.1.2

4 years ago

7.1.1

4 years ago

7.1.0

4 years ago

7.0.10

4 years ago

7.0.9

4 years ago

7.0.8

4 years ago

7.0.7

4 years ago

7.0.6

4 years ago

7.0.5

5 years ago

7.0.4

5 years ago

7.0.3

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.0.0

5 years ago

6.0.0-beta.9

5 years ago

5.3.5

5 years ago

6.0.0-beta.8

5 years ago

6.0.0-beta.7

5 years ago

6.0.0-beta.6

5 years ago

6.0.0-beta.5

5 years ago

6.0.0-beta.4

5 years ago

5.3.4

5 years ago

5.3.3

5 years ago

6.0.0-beta.3

5 years ago

5.3.2

5 years ago

5.3.1

5 years ago

6.0.0-beta.2

5 years ago

6.0.0-beta.1

5 years ago

5.3.0

5 years ago

5.2.0

5 years ago

5.2.0-beta.9

5 years ago

5.2.0-beta.8

5 years ago

5.2.0-beta.7

5 years ago

5.1.15

5 years ago

5.1.14

5 years ago

5.1.13

5 years ago

5.1.12

5 years ago

5.1.11

5 years ago

5.1.10

6 years ago

5.1.9

6 years ago

5.1.8

6 years ago

5.1.7

6 years ago

5.1.6

6 years ago

5.1.5

6 years ago

5.2.0-beta.6

6 years ago

5.1.4

6 years ago

5.2.0-beta.5

6 years ago

5.1.3

6 years ago

5.2.0-beta.4

6 years ago

5.2.0-beta.3

6 years ago

5.2.0-beta.2

6 years ago

5.1.2

6 years ago

5.2.0-beta.1

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.6

6 years ago

5.0.5

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.4

6 years ago

3.3.3

6 years ago

3.3.2

6 years ago

3.3.1

7 years ago

3.3.0

7 years ago

3.2.5

7 years ago

3.2.4

7 years ago

3.2.3

7 years ago

3.2.2

7 years ago

3.2.1

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.7.0

7 years ago

2.6.4

7 years ago

2.6.3

7 years ago

2.6.2

7 years ago

2.6.1

7 years ago

2.6.0

7 years ago

2.5.0

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago