Skip to content

Commit b4be8d3

Browse files
refactor: use npm provenance (OIDC) for tokenless publishing
No OTP or npm automation token needed. GitHub Actions OIDC identity authenticates directly with npm registry.
1 parent ff0b767 commit b4be8d3

2 files changed

Lines changed: 117 additions & 155 deletions

File tree

.github/workflows/release.yml

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,45 @@ env:
1010

1111
permissions:
1212
contents: write
13+
id-token: write
1314

1415
jobs:
16+
publish-crates:
17+
name: Publish Rust crates
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: dtolnay/rust-toolchain@stable
23+
24+
- uses: Swatinem/rust-cache@v2
25+
26+
- name: Publish srcmap-codec
27+
run: cargo publish -p srcmap-codec || echo "Already published, skipping"
28+
env:
29+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
30+
31+
- name: Wait for crates.io index
32+
run: sleep 30
33+
34+
- name: Publish srcmap-sourcemap
35+
run: cargo publish -p srcmap-sourcemap || echo "Already published, skipping"
36+
env:
37+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
38+
39+
- name: Publish srcmap-generator
40+
run: cargo publish -p srcmap-generator || echo "Already published, skipping"
41+
env:
42+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
43+
44+
- name: Wait for crates.io index
45+
run: sleep 30
46+
47+
- name: Publish srcmap-remapping
48+
run: cargo publish -p srcmap-remapping || echo "Already published, skipping"
49+
env:
50+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
51+
1552
build-napi:
1653
name: Build NAPI - ${{ matrix.settings.target }}
1754
runs-on: ${{ matrix.settings.host }}
@@ -128,10 +165,89 @@ jobs:
128165
path: packages/sourcemap-wasm/pkg/
129166
if-no-files-found: error
130167

168+
publish-npm:
169+
name: Publish npm packages
170+
runs-on: ubuntu-latest
171+
needs: [build-napi, build-wasm]
172+
steps:
173+
- uses: actions/checkout@v4
174+
175+
- uses: actions/setup-node@v4
176+
with:
177+
node-version: 20
178+
registry-url: https://registry.npmjs.org
179+
180+
- name: Install @napi-rs/cli
181+
run: npm install -g @napi-rs/cli
182+
183+
- name: Download all codec NAPI artifacts
184+
uses: actions/download-artifact@v4
185+
with:
186+
path: packages/codec/artifacts
187+
pattern: codec-bindings-*
188+
merge-multiple: false
189+
190+
- name: Download all sourcemap NAPI artifacts
191+
uses: actions/download-artifact@v4
192+
with:
193+
path: packages/sourcemap/artifacts
194+
pattern: sourcemap-bindings-*
195+
merge-multiple: false
196+
197+
- name: Download WASM artifact
198+
uses: actions/download-artifact@v4
199+
with:
200+
name: wasm-package
201+
path: packages/sourcemap-wasm/pkg
202+
203+
- name: Move codec artifacts
204+
run: napi artifacts -d artifacts
205+
working-directory: packages/codec
206+
207+
- name: Move sourcemap artifacts
208+
run: napi artifacts -d artifacts
209+
working-directory: packages/sourcemap
210+
211+
- name: Publish @srcmap/codec platform packages
212+
run: |
213+
for dir in npm/*/; do
214+
npm publish "$dir" --access public --provenance || echo "Skipping $(basename "$dir")"
215+
done
216+
working-directory: packages/codec
217+
env:
218+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
219+
220+
- name: Publish @srcmap/codec
221+
run: npm publish --access public --provenance --ignore-scripts
222+
working-directory: packages/codec
223+
env:
224+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
225+
226+
- name: Publish @srcmap/sourcemap platform packages
227+
run: |
228+
for dir in npm/*/; do
229+
npm publish "$dir" --access public --provenance || echo "Skipping $(basename "$dir")"
230+
done
231+
working-directory: packages/sourcemap
232+
env:
233+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
234+
235+
- name: Publish @srcmap/sourcemap
236+
run: npm publish --access public --provenance --ignore-scripts
237+
working-directory: packages/sourcemap
238+
env:
239+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
240+
241+
- name: Publish @srcmap/sourcemap-wasm
242+
run: npm publish --access public --provenance --ignore-scripts
243+
working-directory: packages/sourcemap-wasm
244+
env:
245+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
246+
131247
create-release:
132248
name: Create GitHub Release
133249
runs-on: ubuntu-latest
134-
needs: [build-napi, build-wasm]
250+
needs: [publish-crates, publish-npm]
135251
steps:
136252
- uses: actions/checkout@v4
137253

scripts/release.sh

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)