@@ -22,13 +22,15 @@ const checkout = new Step({
2222const installNode = new Step ( {
2323 name : 'Install Node' ,
2424 uses : 'actions/setup-node@v4' ,
25- with : { 'node-version' : 20 } ,
25+ // npm trusted publishing (OIDC) requires Node >= 22.14
26+ with : { 'node-version' : 24 } ,
2627} )
2728
2829const installPnpm = new Step ( {
2930 name : 'Install pnpm' ,
3031 uses : 'pnpm/action-setup@v4' ,
31- with : { version : 9 } ,
32+ // pnpm 10 supports OIDC trusted publishing; reads the same v9 lockfile
33+ with : { version : 10 } ,
3234} )
3335
3436const installDependencies = new Step ( {
@@ -54,14 +56,10 @@ const bumpVersions = new Step({
5456 ` ) ,
5557} )
5658
57- const setupNpmAuth = new Step ( {
58- name : 'Setup npm auth' ,
59- run : 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc' ,
60- env : {
61- NPM_TOKEN : ex . secret ( 'NPM_TOKEN' ) ,
62- } ,
63- } )
64-
59+ // Auth is handled by npm trusted publishing (OIDC): the job's id-token
60+ // permission lets pnpm mint a short-lived token from the runner's OIDC
61+ // identity. The trusted publisher configured on npmjs.com must reference
62+ // this workflow file (publish.yml).
6563const publishPackages = new Step ( {
6664 name : 'Publish packages' ,
6765 run : dedentString ( `
@@ -77,16 +75,14 @@ const publishPackages = new Step({
7775 pnpm -r publish --access public --no-git-checks
7876 fi
7977 ` ) ,
80- env : {
81- NPM_TOKEN : ex . secret ( 'NPM_TOKEN' ) ,
82- } ,
8378} )
8479
8580const publishJob = new NormalJob ( 'PublishPackages' , {
8681 'runs-on' : 'ubuntu-latest' ,
8782 'timeout-minutes' : 20 ,
8883 permissions : {
8984 contents : 'write' ,
85+ 'id-token' : 'write' ,
9086 } ,
9187} ) . addSteps ( [
9288 checkout ,
@@ -95,7 +91,6 @@ const publishJob = new NormalJob('PublishPackages', {
9591 installDependencies ,
9692 build ,
9793 bumpVersions ,
98- setupNpmAuth ,
9994 publishPackages ,
10095] )
10196
@@ -139,14 +134,15 @@ export const publishWorkflow = new Workflow('publish', {
139134 release : {
140135 types : [ 'published' ] ,
141136 } ,
142- workflow_call : {
137+ // Dispatched (not workflow_call) by draft.yml for beta releases: npm
138+ // trusted publishing validates the top-level workflow's filename, and a
139+ // package can only have one trusted publisher — so every publish must
140+ // run with publish.yml as the top-level workflow.
141+ workflow_dispatch : {
143142 inputs : {
144143 tag_name : { required : true , type : 'string' } ,
145144 target_commitish : { required : true , type : 'string' } ,
146145 } ,
147- secrets : {
148- NPM_TOKEN : { required : true } ,
149- } ,
150146 } ,
151147 } ,
152148} ) . addJobs ( [ publishJob , commitVersionBumpJob ] )
0 commit comments