Skip to content

Commit 28d08b1

Browse files
Document npm trusted publishers (#616)
* Document npm truster publishers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Log when there is no npm token * cleanup * More cleanup * specify with setup-node --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8a519e3 commit 28d08b1

File tree

13 files changed

+109
-39
lines changed

13 files changed

+109
-39
lines changed

.github/workflows/check-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
18-
with:
19-
node_version: "24.x"
2018
- name: Install Dependencies
2119
shell: bash
2220
run: |

.github/workflows/generate-changelog.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v4
3434
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
35-
with:
36-
node_version: "24.x"
3735
- name: Install Dependencies
3836
shell: bash
3937
run: |

.github/workflows/prep-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v4
3434
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
35-
with:
36-
node_version: "24.x"
3735
- name: Install Dependencies
3836
shell: bash
3937
run: |

.github/workflows/prep-self-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@v4
3333
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
34-
with:
35-
node_version: "24.x"
3634
- name: Install Dependencies
3735
shell: bash
3836
run: |

.github/workflows/publish-changelog.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
19-
with:
20-
node_version: "24.x"
2119

2220
- name: Install Dependencies
2321
shell: bash

.github/workflows/publish-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
24-
with:
25-
node_version: "24.x"
2624
- name: Install Dependencies
2725
shell: bash
2826
run: |

.github/workflows/publish-self-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
24-
with:
25-
node_version: "24.x"
2624
- name: Install Dependencies
2725
shell: bash
2826
run: |

.github/workflows/test.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v4
2222
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
23-
with:
24-
node_version: "24.x"
2523
- name: Run Linters
2624
run: |
2725
hatch run typing:test
@@ -34,8 +32,6 @@ jobs:
3432
steps:
3533
- uses: actions/checkout@v4
3634
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
37-
with:
38-
node_version: "24.x"
3935
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
4036
with:
4137
ignore_links: https://blog.jupyter.org/.*
@@ -50,8 +46,6 @@ jobs:
5046
steps:
5147
- uses: actions/checkout@v4
5248
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
53-
with:
54-
node_version: "24.x"
5549

5650
- name: Run the tests with coverage on Ubuntu
5751
if: ${{ matrix.os == 'ubuntu-latest' }}
@@ -78,8 +72,6 @@ jobs:
7872
steps:
7973
- uses: actions/checkout@v4
8074
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
81-
with:
82-
node_version: "24.x"
8375
- env:
8476
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8577
RH_REPOSITORY: jupyter-server/jupyter_releaser
@@ -111,7 +103,6 @@ jobs:
111103
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
112104
with:
113105
dependency_type: minimum
114-
node_version: "24.x"
115106
- name: Run the unit tests
116107
run: |
117108
hatch run test:nowarn || hatch run test:nowarn --lf
@@ -126,7 +117,6 @@ jobs:
126117
with:
127118
dependency_type: pre
128119
python_version: "3.12"
129-
node_version: "24.x"
130120
- name: Run the tests
131121
run: |
132122
hatch run test:nowarn || hatch run test:nowarn --lf
@@ -137,17 +127,13 @@ jobs:
137127
steps:
138128
- uses: actions/checkout@v4
139129
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
140-
with:
141-
node_version: "24.x"
142130
- run: hatch run docs:build
143131

144132
check_local_actions:
145133
runs-on: ubuntu-latest
146134
steps:
147135
- uses: actions/checkout@v4
148136
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
149-
with:
150-
node_version: "24.x"
151137

152138
- name: prep-release
153139
uses: ./.github/actions/prep-release

docs/source/get_started/making_release_from_releaser.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,40 @@ 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+
58+
- Ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements))
59+
60+
- Set up the Node.js version in your workflow using one of these approaches:
61+
62+
Using the `base-setup` action from `jupyterlab/maintainer-tools`:
63+
64+
```yaml
65+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
66+
```
67+
68+
Or using the standard `setup-node` action:
69+
70+
```yaml
71+
- uses: actions/setup-node@v6
72+
with:
73+
node-version: "24.x"
74+
```
75+
76+
- With Trusted Publishers enabled, npm packages will be published without needing to store an `NPM_TOKEN` secret
77+
78+
</details>
79+
80+
<details><summary>Using NPM_TOKEN (legacy way)</summary>
81+
82+
- Create an access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN` in "Secrets"
83+
- 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))
84+
85+
</details>
5586

5687
## Prep Release
5788

docs/source/how_to_guides/convert_repo_from_releaser.md

Lines changed: 34 additions & 3 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

@@ -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+
63+
- Ensure the publish release job has `permissions`: `id-token: write` (see the [documentation](https://docs.npmjs.com/generating-provenance-statements))
64+
65+
- Set up the Node.js version in your workflow using one of these approaches:
66+
67+
Using the `base-setup` action from `jupyterlab/maintainer-tools`:
68+
69+
```yaml
70+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
71+
```
72+
73+
Or using the standard `setup-node` action:
74+
75+
```yaml
76+
- uses: actions/setup-node@v6
77+
with:
78+
node-version: "24.x"
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

0 commit comments

Comments
 (0)