Skip to content

Commit ac6491c

Browse files
committed
Document npm truster publishers
1 parent 6accaa3 commit ac6491c

File tree

4 files changed

+112
-19
lines changed

4 files changed

+112
-19
lines changed

docs/source/get_started/making_release_from_releaser.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,38 @@ already uses Jupyter Releaser.
4949
5050
</details>
5151
52-
- If the repo generates npm release(s), add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN` in "Secrets".
52+
- If the repo generates npm release(s), set up npm:
5353
54-
> If you want to set _provenance_ on your package, you need to ensure the publish release job as `permissions`: `id-token : write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions)).
54+
<details><summary>Using npm Trusted Publishers (recommended)</summary>
55+
56+
- npm Trusted Publishers is supported with npm >= 11.5.1
57+
- Ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements))
58+
- Set up the Node.js version in your workflow using one of these approaches:
59+
60+
Using the `base-setup` action from `jupyterlab/maintainer-tools`:
61+
```yaml
62+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
63+
with:
64+
node_version: "24"
65+
```
66+
67+
Or using the standard `setup-node` action:
68+
```yaml
69+
- uses: actions/setup-node@v6
70+
with:
71+
node-version: "24"
72+
```
73+
74+
- With Trusted Publishers enabled, npm packages will be published without needing to store an `NPM_TOKEN` secret
75+
76+
</details>
77+
78+
<details><summary>Using NPM_TOKEN (legacy way)</summary>
79+
80+
- Create an access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN` in "Secrets"
81+
- If you want to set _provenance_ on your package, you need to ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions))
82+
83+
</details>
5584

5685
## Prep Release
5786

docs/source/how_to_guides/convert_repo_from_releaser.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ See checklist below for details:
1010
- Bump version configuration (if using Python), for example [tbump](https://github.com/dmerejkowsky/tbump)
1111
- [Access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with access to target GitHub repo to run GitHub Actions.
1212
- Access token for the [PyPI registry](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#saving-credentials-on-github)
13-
- If needed, access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens).
13+
- If publishing to npm, we recommend using [npm Trusted Publishers](https://docs.npmjs.com/trusted-publishers) (requires npm >= 11.5.1, available via Node.js >= 24). Otherwise, create an access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens).
1414

1515
## Checklist for Adoption
1616

@@ -19,9 +19,9 @@ A. Prep the `jupyter_releaser` fork:
1919
- [ ] Clone this repository onto your GitHub user account.
2020

2121
- [ ] Add a GitHub [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with access to target GitHub repo to run
22-
GitHub Actions, saved as `ADMIN_GITHUB_TOKEN` in the
23-
[repository secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository).
24-
The token will need "public_repo", and "repo:status" permissions.
22+
GitHub Actions, saved as `ADMIN_GITHUB_TOKEN` in the
23+
[repository secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository).
24+
The token will need "public_repo", and "repo:status" permissions.
2525

2626
- [ ] Set up PyPI:
2727

@@ -54,9 +54,40 @@ A. Prep the `jupyter_releaser` fork:
5454

5555
</details>
5656

57-
- [ ] If needed, add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`.
57+
- [ ] Set up npm (if publishing to npm):
5858

59-
> If you want to set _provenance_ on your package, you need to ensure the publish release job as `permissions`: `id-token : write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions)).
59+
<details><summary>Using npm Trusted Publishers (recommended)</summary>
60+
61+
- npm Trusted Publishers is supported with npm >= 11.5.1
62+
- Ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements))
63+
- Set up the Node.js version in your workflow using one of these approaches:
64+
65+
Using the `base-setup` action from `jupyterlab/maintainer-tools`:
66+
67+
```yaml
68+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
69+
with:
70+
node_version: "24"
71+
```
72+
73+
Or using the standard `setup-node` action:
74+
75+
```yaml
76+
- uses: actions/setup-node@v4
77+
with:
78+
node-version: "24"
79+
```
80+
81+
- With Trusted Publishers enabled, npm packages will be published with provenance automatically, without needing to store an `NPM_TOKEN` secret
82+
83+
</details>
84+
85+
<details><summary>Using NPM_TOKEN (legacy way)</summary>
86+
87+
- Create an access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`
88+
- If you want to set _provenance_ on your package, you need to ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions))
89+
90+
</details>
6091

6192
B. Prep target repository:
6293

@@ -66,7 +97,7 @@ B. Prep target repository:
6697
- Note that [directives](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#syntax-directives) can still be used
6798
- [ ] Add HTML start and end comment markers to Changelog file - see example in [CHANGELOG.md](https://github.com/jupyter-server/jupyter_releaser/blob/main/CHANGELOG.md) (view in raw mode)
6899
- [ ] We recommend using [hatch](https://hatch.pypa.io/latest/) for your
69-
build system and for version handling.
100+
build system and for version handling.
70101
- If previously providing `version_info` like `version_info = (1, 7, 0, '.dev', '0')`, use a pattern like the one below in your version file:
71102

72103
```python
@@ -111,7 +142,7 @@ version_info = tuple(parts)
111142
```
112143

113144
- [ ] Add a workflow that uses the [`enforce-label`](https://github.com/jupyterlab/maintainer-tools#enforce-labels) action from `jupyterlab/maintainer-tools` to ensure that all PRs have on of the triage labels used to
114-
categorize the changelog.
145+
categorize the changelog.
115146

116147
- [ ] Update or add `RELEASE.md` that describes the onboarding and release process, e.g. [jupyter_server](https://github.com/jupyter-server/jupyter_server/blob/main/RELEASE.md).
117148

docs/source/how_to_guides/convert_repo_from_repo.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ See checklist below for details:
99
- Markdown changelog
1010
- Bump version configuration (if using Python), for example [hatch](https://hatch.pypa.io/latest/)
1111
- [Add a trusted publisher](https://docs.pypi.org/trusted-publishers/adding-a-publisher/) to your PyPI project
12-
- If needed, access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens).
12+
- If publishing to npm, we recommend using [npm Trusted Publishers](https://docs.npmjs.com/trusted-publishers) (requires npm >= 11.5.1, available via Node.js >= 24). Otherwise, create an access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens).
1313

1414
## Checklist for Adoption
1515

@@ -25,7 +25,7 @@ See checklist below for details:
2525
- Store the `APP_ID` and the private key in a secure location (Jupyter Vault if using a Jupyter Org)
2626

2727
- [ ] Create a "release" [environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment) on your repository and add an `APP_ID` Environment Variable and `APP_PRIVATE_KEY` secret.
28-
The environment should be enabled for ["Protected branches only"](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-branches-and-tags).
28+
The environment should be enabled for ["Protected branches only"](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-branches-and-tags).
2929

3030
- [ ] Configure [Rulesets](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets) for the repository
3131

@@ -38,7 +38,7 @@ See checklist below for details:
3838
- Allow the GitHub App to bypass protections
3939

4040
- [ ] Copy `prep-release.yml` and `publish-release.yml` (or only `full-release.yml`) from the
41-
[example-workflows](https://github.com/jupyter-server/jupyter_releaser/tree/main/example-workflows) folder in this repository.
41+
[example-workflows](https://github.com/jupyter-server/jupyter_releaser/tree/main/example-workflows) folder in this repository.
4242

4343
- [ ] Set up PyPI:
4444

@@ -47,8 +47,41 @@ See checklist below for details:
4747
_environment_ should be `release` (the name of the GitHub environment).
4848
- Ensure the publish release job as `permissions`: `id-token : write` (see the [documentation](https://docs.pypi.org/trusted-publishers/using-a-publisher/))
4949

50-
- [ ] If needed, add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`. Again this should
51-
be created using a machine account that only has publish access.
50+
- [ ] Set up npm (if publishing to npm):
51+
52+
<details><summary>Using npm Trusted Publishers (recommended)</summary>
53+
54+
- npm Trusted Publishers is supported with npm >= 11.5.1
55+
- Ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements))
56+
- Set up the Node.js version in your workflow using one of these approaches:
57+
58+
Using the `base-setup` action from `jupyterlab/maintainer-tools`:
59+
60+
```yaml
61+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
62+
with:
63+
node_version: "24"
64+
```
65+
66+
Or using the standard `setup-node` action:
67+
68+
```yaml
69+
- uses: actions/setup-node@v4
70+
with:
71+
node-version: "24"
72+
```
73+
74+
- With Trusted Publishers enabled, npm packages will be published with provenance automatically, without needing to store an `NPM_TOKEN` secret
75+
76+
</details>
77+
78+
<details><summary>Using NPM_TOKEN (legacy way)</summary>
79+
80+
- Create an access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`
81+
- This should be created using a machine account that only has publish access
82+
- If you want to set _provenance_ on your package, you need to ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions))
83+
84+
</details>
5285

5386
- [ ] Ensure that only trusted users with 2FA have admin access to the repository, since they will be able to trigger releases.
5487

@@ -71,7 +104,7 @@ See checklist below for details:
71104
```
72105

73106
- [ ] We recommend using [hatch](https://hatch.pypa.io/latest/) for your
74-
build system and for version handling.
107+
build system and for version handling.
75108
- If previously providing `version_info` like `version_info = (1, 7, 0, '.dev', '0')`,
76109
use a pattern like the one below in your version file:
77110

@@ -119,7 +152,7 @@ version_info = tuple(parts)
119152
```
120153

121154
- [ ] Add a workflow that uses the [`enforce-label`](https://github.com/jupyterlab/maintainer-tools#enforce-labels) action
122-
from `jupyterlab/maintainer-tools` to ensure that all PRs have on of the triage labels used to categorize the changelog.
155+
from `jupyterlab/maintainer-tools` to ensure that all PRs have on of the triage labels used to categorize the changelog.
123156

124157
```yaml
125158
name: Enforce PR label
@@ -149,7 +182,7 @@ jobs:
149182
- [ ] Try out the `Prep Release` and `Publish Release` process against a fork of the target repo first so you don't accidentally push tags and GitHub releases to the source repository. Set the `TWINE_REPOSITORY_URL` environment variable to `https://test.pypi.org/legacy/` in the "Finalize Release" action part of the workflow
150183

151184
- [ ] Try the `Publish Release` process using a prerelease version on the main
152-
repository before publishing a final version.
185+
repository before publishing a final version.
153186

154187
## Backport Branches
155188

docs/source/reference/theory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This project should help maintainers reduce toil and save time in the release pr
1717

1818
We strive to use the most secure release practices possible, reflected in the `Checklist for Adoption`
1919
and the example workflows.
20-
This includes using PyPI Trusted Publishing, using GitHub Environments, encouraging the use of Rulesets and GitHub Apps with limited bypass capability, and provenance data for npm.
20+
This includes using PyPI Trusted Publishing, npm Trusted Publishers (with npm >= 11.5.1), using GitHub Environments, encouraging the use of Rulesets and GitHub Apps with limited bypass capability, and provenance data for npm.
2121
In addition, there is an automatic check for whether the user who triggered the action is an admin.
2222

2323
## Action Details

0 commit comments

Comments
 (0)