Skip to content

Commit e5c9857

Browse files
committed
docs(trusted-publishing): add details to the readme for configuring within GitLab Pipelines
for #958
1 parent 23c8610 commit e5c9857

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ 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+
> [!NOTE]
51+
> When using trusted publishing, provenance attestations are automatically generated for your packages without requiring provenance to be explicitly enabled.
52+
5053
#### Trusted publishing from GitHub Actions
5154

52-
To publish with OIDC from GitHub Actions, the `id-token: write` permission is required 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:
5356

5457
```yaml
5558
permissions:
5659
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
5760
```
5861
59-
> [!NOTE]
60-
> When using trusted publishing, provenance attestations are automatically generated for your packages without requiring provenance to be explicitly enabled.
61-
6262
It's also worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments,
6363
and other features, then [more permissions are required](https://github.com/semantic-release/github#github-authentication) to be enabled on this job:
6464
@@ -72,6 +72,18 @@ permissions:
7272
7373
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.
7474
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 detail about configuring pipeline details](https://docs.npmjs.com/trusted-publishers#gitlab-cicd-configuration)
86+
7587
### Alternative Registries
7688

7789
The npm token authentication configuration is **required** and can be set via [environment variables](#environment-variables).

0 commit comments

Comments
 (0)