Skip to content

Commit f739331

Browse files
committed
Add trusted publishing workflow for npm
1 parent 47652a7 commit f739331

2 files changed

Lines changed: 31 additions & 10 deletions

File tree

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
name: Publish to npm
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
contents: read
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
- uses: pnpm/action-setup@v4
20+
with:
21+
version: 10
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: '22'
25+
cache: pnpm
26+
registry-url: 'https://registry.npmjs.org'
27+
- run: pnpm install --frozen-lockfile
28+
- run: pnpm build
29+
- run: pnpm publish -r --access public --no-git-checks

scripts/release.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,16 @@ console.log('Updated packages/lib/src/version.ts')
6363
console.log('\nBuilding all packages...')
6464
run('pnpm build')
6565

66-
// Publish packages in order
67-
console.log('\nPublishing packages...')
68-
for (const pkg of packages) {
69-
const pkgDir = path.join(rootDir, 'packages', pkg)
70-
console.log(`\nPublishing ${pkg}...`)
71-
run('pnpm publish --no-git-checks --access public', pkgDir)
72-
}
73-
7466
// Git operations
7567
const tag = `v${newVersion}`
7668
console.log(`\nCreating git tag ${tag}...`)
7769
run('git add -A')
7870
run(`git commit -m "${tag}"`)
7971
run(`git tag -a "${tag}" -m "${tag}"`)
80-
run('git push --follow-tags')
72+
run('git push && git push --tags')
8173

8274
// Deploy app to GitHub Pages
8375
console.log('\nDeploying app to GitHub Pages...')
8476
run('pnpm run deploy', path.join(rootDir, 'packages/app'))
8577

86-
console.log(`\n✓ Successfully released ${tag} and deployed app`)
78+
console.log(`\n✓ Released ${tag} — GitHub Actions will publish to npm`)

0 commit comments

Comments
 (0)