@@ -110,38 +110,22 @@ jobs:
110110 if-no-files-found : error
111111 retention-days : 1
112112
113- # Combine native addons from all platforms and publish a single npm package.
114- # Runs on a self-hosted Linux runner (not ubuntu-latest) because just setup
115- # needs to build the Rust runtime which requires hyperlight toolchain.
116- publish-npm :
117- name : Publish to npmjs.org
113+ # Assemble the final npm package tarball on a self-hosted Linux runner
114+ # (needs `just setup` for the hyperlight toolchain to build the binary).
115+ # The resulting tarball is uploaded as an artifact, then published from a
116+ # github-hosted runner — npm sigstore provenance *requires* github-hosted.
117+ pack-npm :
118+ name : Pack npm tarball
118119 needs : [build-native]
119- # id-token: write is required for npm OIDC trusted publishing;
120- # contents: read for checkout. Scoped to this job only (least privilege).
121120 permissions :
122121 contents : read
123- id-token : write
124- runs-on : [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd","JobId=hyperagent-publish-npm-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"]
122+ runs-on : [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd","JobId=hyperagent-pack-npm-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"]
125123 steps :
126124 - uses : actions/checkout@v6
127125
128126 - uses : actions/setup-node@v6
129127 with :
130128 node-version : " 22"
131- registry-url : " https://registry.npmjs.org"
132-
133- # Trusted publishing requires npm >=11.5.1 for OIDC token exchange.
134- # Pin to ^11.5.1 so we don't silently get an older 11.x that lacks OIDC.
135- #
136- # Bootstrap via `npx` rather than `npm install -g npm@...` — the latter
137- # hits a long-standing npm self-upgrade bug on self-hosted runners where
138- # mid-reify npm unlinks its own `promise-retry` dep and dies with
139- # MODULE_NOT_FOUND. Using a fresh npx-fetched npm to install itself
140- # globally sidesteps the half-upgraded state entirely.
141- - name : Upgrade npm for trusted publishing
142- run : |
143- npx --yes npm@^11.5.1 install -g --force npm@^11.5.1
144- npm --version
145129
146130 - uses : hyperlight-dev/ci-setup-workflow@v1.9.0
147131 with :
@@ -172,6 +156,47 @@ jobs:
172156 if : github.event_name == 'workflow_dispatch'
173157 run : npm version ${{ inputs.version }} --no-git-tag-version --allow-same-version
174158
159+ - name : Pack npm tarball
160+ run : npm pack
161+
162+ - name : Upload npm tarball
163+ uses : actions/upload-artifact@v7
164+ with :
165+ name : npm-tarball
166+ path : " *.tgz"
167+ if-no-files-found : error
168+ retention-days : 1
169+
170+ # Publish the prebuilt tarball from a github-hosted runner.
171+ # npm sigstore provenance (--provenance) only accepts github-hosted runners;
172+ # self-hosted is rejected with:
173+ # E422 Unsupported GitHub Actions runner environment: "self-hosted"
174+ # This job does no building — it just takes the tarball and pushes it.
175+ publish-npm :
176+ name : Publish to npmjs.org
177+ needs : [pack-npm]
178+ # id-token: write is required for npm OIDC trusted publishing;
179+ # contents: read for checkout. Scoped to this job only (least privilege).
180+ permissions :
181+ contents : read
182+ id-token : write
183+ runs-on : ubuntu-latest
184+ steps :
185+ - uses : actions/setup-node@v6
186+ with :
187+ node-version : " 22"
188+ registry-url : " https://registry.npmjs.org"
189+
190+ # Trusted publishing requires npm >=11.5.1 for OIDC token exchange.
191+ # Pin to ^11.5.1 so we don't silently get an older 11.x that lacks OIDC.
192+ - name : Upgrade npm for trusted publishing
193+ run : npm install -g npm@^11.5.1 && npm --version
194+
195+ - name : Download npm tarball
196+ uses : actions/download-artifact@v8
197+ with :
198+ name : npm-tarball
199+
175200 # OIDC trusted publishing for release events; NPM_TOKEN fallback for workflow_dispatch
176201 - name : Set publish flags
177202 id : publish-flags
@@ -183,7 +208,7 @@ jobs:
183208 fi
184209
185210 - name : Publish to npmjs.org
186- run : npm publish --access public ${{ steps.publish-flags.outputs.provenance }}
211+ run : npm publish *.tgz --access public ${{ steps.publish-flags.outputs.provenance }}
187212 env :
188213 NODE_AUTH_TOKEN : ${{ github.event_name == 'workflow_dispatch' && secrets.NPM_TOKEN || '' }}
189214
0 commit comments