Skip to content

Commit 66e2a44

Browse files
committed
docs(trusted-publsihing): combine information about configuring github actions
for both trusted publishing and provenance attestations for #958
1 parent 4a8cd7a commit 66e2a44

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

README.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,45 +47,36 @@ When publishing to the [official registry](https://registry.npmjs.org/), it is r
4747
- [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).
4848
Because these access tokens expire, rotation will need to be accounted for in this scenario.
4949

50-
### Alternative Registries
51-
52-
The npm token authentication configuration is **required** and can be set via [environment variables](#environment-variables).
53-
See the documentation for your registry for details on how to create a token for automation.
54-
55-
### npm provenance
56-
57-
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).
58-
59-
Since semantic-release wraps the npm publish command, configuring provenance is not exposed directly.
60-
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).
61-
Provenance applies specifically to publishing, so our recommendation is to configure under `publishConfig` within the `package.json`.
62-
63-
> [!NOTE]
64-
> When publishing a public package to the official registry with OIDC, [npm provenance is automatically enabled](https://docs.npmjs.com/trusted-publishers#automatic-provenance-generation) and does not require any additional configuration.
50+
#### Trusted publishing from GitHub Actions
6551

66-
#### npm provenance on GitHub Actions
67-
68-
For package provenance to be signed on the GitHub Actions CI the following permission is required
69-
to be enabled on the job:
52+
To publish with OIDC from GitHub Actions, the `id-token: write` permission is required to be enabled on the job:
7053

7154
```yaml
7255
permissions:
73-
id-token: write # to enable use of OIDC for npm provenance
56+
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
7457
```
7558
76-
It's worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments,
59+
> [!NOTE]
60+
> When using trusted publishing, provenance attestations are automatically generated for your packages without requiring provenance to be explicitly enabled.
61+
62+
It's also worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments,
7763
and other features, then [more permissions are required](https://github.com/semantic-release/github#github-authentication) to be enabled on this job:
7864
7965
```yaml
8066
permissions:
8167
contents: write # to be able to publish a GitHub release
8268
issues: write # to be able to comment on released issues
8369
pull-requests: write # to be able to comment on released pull requests
84-
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
8571
```
8672
8773
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.
8874
75+
### Alternative Registries
76+
77+
The npm token authentication configuration is **required** and can be set via [environment variables](#environment-variables).
78+
See the documentation for your registry for details on how to create a token for automation.
79+
8980
### Environment variables
9081
9182
| Variable | Description |
@@ -110,13 +101,14 @@ The plugin uses the [`npm` CLI](https://github.com/npm/cli) which will read the
110101

111102
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`.
112103

113-
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`:
104+
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`:
114105

115106
```json
116107
{
117108
"publishConfig": {
118109
"registry": "https://registry.npmjs.org/",
119-
"tag": "latest"
110+
"tag": "latest",
111+
"provenance": true
120112
}
121113
}
122114
```

0 commit comments

Comments
 (0)