You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-16Lines changed: 39 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,41 +38,63 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
38
38
39
39
### npm registry authentication
40
40
41
-
The npm [token](https://docs.npmjs.com/about-access-tokens) authentication configuration is **required** and can be set via [environment variables](#environment-variables).
41
+
### Official Registry
42
42
43
-
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](https://docs.npmjs.com/about-two-factor-authentication#authorization-and-writes).
43
+
When publishing to the [official registry](https://registry.npmjs.org/), it is recommended to publish with authentication intended for automation:
44
44
45
-
### npm provenance
45
+
- For improved security, and since access tokens have recently had their [maximum lifetimes restricted](https://github.blog/changelog/2025-09-29-strengthening-npm-security-important-changes-to-authentication-and-token-management/),
46
+
[trusted publishing](https://docs.npmjs.com/trusted-publishers) is recommended when publishing from a [supported CI provider](https://docs.npmjs.com/trusted-publishers#supported-cicd-providers)
47
+
-[Granular access tokens](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website) are recommended when publishing from a CI provider that is not supported by npm for trusted publishing, and can be set via [environment variables](#environment-variables).
48
+
Because these access tokens expire, rotation will need to be accounted for in this scenario.
46
49
47
-
If you are publishing to the official registry and your pipeline is on a [provider that is supported by npm for provenance](https://docs.npmjs.com/generating-provenance-statements#provenance-limitations), npm can be configured to [publish with provenance](https://docs.npmjs.com/generating-provenance-statements).
50
+
> [!NOTE]
51
+
> When using trusted publishing, provenance attestations are automatically generated for your packages without requiring provenance to be explicitly enabled.
48
52
49
-
Since semantic-release wraps the npm publish command, configuring provenance is not exposed directly.
50
-
Instead, provenance can be configured through the [other configuration options exposed by npm](https://docs.npmjs.com/generating-provenance-statements#using-third-party-package-publishing-tools).
51
-
Provenance applies specifically to publishing, so our recommendation is to configure under `publishConfig` within the `package.json`.
53
+
#### Trusted publishing from GitHub Actions
52
54
53
-
#### npm provenance on GitHub Actions
54
-
55
-
For package provenance to be signed on the GitHub Actions CI the following permission is required
56
-
to be enabled on the job:
55
+
To leverage trusted publishing and publish with provenance from GitHub Actions, the `id-token: write` permission is required to be enabled on the job:
57
56
58
57
```yaml
59
58
permissions:
60
-
id-token: write # to enable use of OIDC for npm provenance
59
+
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
61
60
```
62
61
63
-
It's worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments,
62
+
It's also worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments,
64
63
and other features, then [more permissions are required](https://github.com/semantic-release/github#github-authentication) to be enabled on this job:
65
64
66
65
```yaml
67
66
permissions:
68
67
contents: write # to be able to publish a GitHub release
69
68
issues: write # to be able to comment on released issues
70
69
pull-requests: write # to be able to comment on released pull requests
71
-
id-token: write # to enable use of OIDC for npm provenance
70
+
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
72
71
```
73
72
74
73
Refer to the [GitHub Actions recipe for npm package provenance](https://semantic-release.gitbook.io/semantic-release/recipes/ci-configurations/github-actions#.github-workflows-release.yml-configuration-for-node-projects) for the full CI job's YAML code example.
75
74
75
+
#### Trusted publishing for GitLab Pipelines
76
+
77
+
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`:
78
+
79
+
```yaml
80
+
id_tokens:
81
+
NPM_ID_TOKEN:
82
+
aud: "npm:registry.npmjs.org"
83
+
```
84
+
85
+
See the [npm documentation for more details about configuring pipeline details](https://docs.npmjs.com/trusted-publishers#gitlab-cicd-configuration)
86
+
87
+
#### Unsupported CI providers
88
+
89
+
Token authentication is **required** and can be set via [environment variables](#environment-variables).
90
+
[Granular access tokens](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website) are recommended in this scenario, since trusted publishing is not available from all CI providers.
91
+
Because these access tokens expire, rotation will need to be accounted for in your process.
92
+
93
+
### Alternative Registries
94
+
95
+
Token authentication is **required** and can be set via [environment variables](#environment-variables).
96
+
See the documentation for your registry for details on how to create a token for automation.
97
+
76
98
### Environment variables
77
99
78
100
| Variable | Description |
@@ -97,13 +119,14 @@ The plugin uses the [`npm` CLI](https://github.com/npm/cli) which will read the
97
119
98
120
The [`registry`](https://docs.npmjs.com/misc/registry) can be configured via the npm environment variable `NPM_CONFIG_REGISTRY` and will take precedence over the configuration in `.npmrc`.
99
121
100
-
The [`registry`](https://docs.npmjs.com/misc/registry) and [`dist-tag`](https://docs.npmjs.com/cli/dist-tag) can be configured under `publishConfig` in the `package.json`:
122
+
The [`registry`](https://docs.npmjs.com/misc/registry), [`dist-tag`](https://docs.npmjs.com/cli/dist-tag), and [`provenance`](https://docs.npmjs.com/generating-provenance-statements#using-third-party-package-publishing-tools) can be configured under `publishConfig` in the `package.json`:
Copy file name to clipboardExpand all lines: lib/definitions/errors.js
+14-6Lines changed: 14 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -37,11 +37,22 @@ Your configuration for the \`pkgRoot\` option is \`${pkgRoot}\`.`,
37
37
exportfunctionENONPMTOKEN({ registry }){
38
38
return{
39
39
message: "No npm token specified.",
40
-
details: `An [npm token](${linkify(
40
+
details: `When not publishing through [trusted publishing](https://docs.npmjs.com/trusted-publishers), an [npm token](${linkify(
41
41
"README.md#npm-registry-authentication"
42
42
)}) must be created and set in the \`NPM_TOKEN\` environment variable on your CI environment.
43
43
44
-
Please make sure to create an [npm token](https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens) and to set it in the \`NPM_TOKEN\` environment variable on your CI environment. The token must allow to publish to the registry \`${registry}\`.`,
44
+
Please make sure to create an [npm token](https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens) and set it in the \`NPM_TOKEN\` environment variable on your CI environment. The token must allow publishing to the registry \`${registry}\`.`,
45
+
};
46
+
}
47
+
48
+
exportfunctionEINVALIDNPMAUTH({ registry }){
49
+
return{
50
+
message: "Invalid npm authentication.",
51
+
details: `The [authentication required to publish](${linkify(
52
+
"README.md#npm-registry-authentication"
53
+
)}) configured in the \`NPM_TOKEN\` environment variable must be a valid [token](https://docs.npmjs.com/getting-started/working_with_tokens) allowed to publish to the registry \`${registry}\`.
54
+
55
+
Please make sure to set the \`NPM_TOKEN\` environment variable in your CI with the exact value of the npm token.`,
45
56
};
46
57
}
47
58
@@ -52,10 +63,7 @@ export function EINVALIDNPMTOKEN({ registry }) {
52
63
"README.md#npm-registry-authentication"
53
64
)}) configured in the \`NPM_TOKEN\` environment variable must be a valid [token](https://docs.npmjs.com/getting-started/working_with_tokens) allowing to publish to the registry \`${registry}\`.
54
65
55
-
If you are using Two Factor Authentication for your account, set its level to ["Authorization only"](https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) in your account settings. **semantic-release** cannot publish with the default "
56
-
Authorization and writes" level.
57
-
58
-
Please make sure to set the \`NPM_TOKEN\` environment variable in your CI with the exact value of the npm token.`,
66
+
Please verify your authentication configuration.`,
0 commit comments