Skip to content

Commit cac44d3

Browse files
committed
ci(release): use npm trusted publishing
1 parent b0adcd3 commit cac44d3

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88

9+
permissions: {}
10+
911
jobs:
1012
verify:
1113
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')
@@ -20,7 +22,7 @@ jobs:
2022

2123
steps:
2224
- name: Check out repository
23-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2426
with:
2527
fetch-depth: 0
2628
persist-credentials: false
@@ -52,22 +54,23 @@ jobs:
5254
deployment: false
5355
permissions:
5456
contents: read
57+
id-token: write
5558

5659
steps:
5760
- name: Create release bot token
5861
id: release-bot
59-
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
62+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
6063
with:
6164
client-id: ${{ vars.PUTIO_RELEASE_BOT_CLIENT_ID }}
6265
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
6366
permission-contents: write
6467
permission-issues: write
6568
permission-pull-requests: write
6669
- name: Check out repository
67-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
70+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6871
with:
6972
fetch-depth: 0
70-
token: ${{ steps.release-bot.outputs.token }}
73+
persist-credentials: false
7174

7275
- name: Set up Vite+
7376
uses: voidzero-dev/setup-vp@ca1c46663915d6c1042ae23bd39ab85718bfb0fa # v1.10.0
@@ -78,6 +81,11 @@ jobs:
7881
- name: Install dependencies
7982
run: vp install
8083

84+
- name: Configure release bot remote
85+
run: git remote set-url origin "https://x-access-token:${RELEASE_BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
86+
env:
87+
RELEASE_BOT_TOKEN: ${{ steps.release-bot.outputs.token }}
88+
8189
- name: Release package
8290
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
8391
with:
@@ -90,7 +98,6 @@ jobs:
9098
conventional-changelog-conventionalcommits@9.3.1
9199
env:
92100
GITHUB_TOKEN: ${{ steps.release-bot.outputs.token }}
93-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
94101
GIT_AUTHOR_NAME: ${{ steps.release-bot.outputs.app-slug }}[bot]
95102
GIT_AUTHOR_EMAIL: ${{ steps.release-bot.outputs.app-slug }}[bot]@users.noreply.github.com
96103
GIT_COMMITTER_NAME: ${{ steps.release-bot.outputs.app-slug }}[bot]

docs/DISTRIBUTION.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,22 @@ Release jobs declare the protected GitHub Environment named `release`.
1818

1919
Environment entries:
2020

21-
- secrets: `NPM_TOKEN`, `PUTIO_RELEASE_BOT_PRIVATE_KEY`
21+
- secrets: `PUTIO_RELEASE_BOT_PRIVATE_KEY`
2222
- variables: `PUTIO_RELEASE_BOT_CLIENT_ID`
2323
- approval: none; releases are continuous after the `main` gate passes
2424
- refs: release branch/tag policy constrains what can publish
2525
- deployment records: disabled with `deployment: false` because this is package publishing, not an app deploy
2626

2727
Release GitHub writes use `putio-release-bot` for version sync commits, `v*` tags, GitHub Releases, and release notes.
2828

29+
The npm package uses Trusted Publishing from GitHub Actions. On npm, configure owner `putdotio`, repository `putio-sockjs`, workflow `ci.yml`, and Environment named `release` for the package.
30+
31+
The workflow grants `id-token: write` so npm can mint short-lived publish credentials and provenance; do not add a long-lived `NPM_TOKEN` secret.
32+
2933
The workflow keeps dependency caches only on the secretless verify job. The secret-bearing release job runs a fresh `vp install` with package-manager caching disabled before publishing to npm.
3034

35+
The release-bot remote is configured only after dependencies are installed.
36+
3137
## Local Checks
3238

3339
Before changing distribution wiring, validate the repo-local guardrails the workflow depends on:

0 commit comments

Comments
 (0)