72
72
name : Test
73
73
strategy :
74
74
matrix :
75
- platform : [ubuntu-latest, windows-latest, macos-latest]
75
+ platform : [ ubuntu-latest, windows-latest, macos-latest ]
76
76
fail-fast : false
77
77
runs-on : ${{ matrix.platform }}
78
78
steps :
@@ -249,22 +249,30 @@ jobs:
249
249
components : rust-src
250
250
- name : Cache Rust workspace
251
251
uses : Swatinem/rust-cache@v2
252
+ - name : Setup Node
253
+ uses : actions/setup-node@v4
254
+ with :
255
+ node-version : lts/*
252
256
- name : Install dependencies
253
- run : npm -C objdiff-wasm install
257
+ run : npm -C objdiff-wasm ci
254
258
- name : Build
255
259
run : npm -C objdiff-wasm run build
260
+ - name : Upload artifacts
261
+ uses : actions/upload-artifact@v4
262
+ with :
263
+ name : wasm
264
+ path : objdiff-wasm/dist/
265
+ if-no-files-found : error
256
266
257
- release :
258
- name : Release
267
+ check-version :
268
+ name : Check package versions
259
269
if : startsWith(github.ref, 'refs/tags/')
260
270
runs-on : ubuntu-latest
261
- needs : [build-cli, build-gui]
262
- permissions :
263
- contents : write
271
+ needs : [ build-cli, build-gui ]
264
272
steps :
265
273
- name : Checkout
266
274
uses : actions/checkout@v4
267
- - name : Check git tag against Cargo version
275
+ - name : Check git tag against package versions
268
276
shell : bash
269
277
run : |
270
278
set -eou pipefail
@@ -276,9 +284,24 @@ jobs:
276
284
echo "::error::Git tag doesn't match the Cargo version! ($tag != $version)"
277
285
exit 1
278
286
fi
287
+ version="v$(jq -r .version objdiff-wasm/package.json)"
288
+ if [ "$tag" != "$version" ]; then
289
+ echo "::error::Git tag doesn't match the npm version! ($tag != $version)"
290
+ exit 1
291
+ fi
292
+
293
+ release-github :
294
+ name : Release (GitHub)
295
+ if : startsWith(github.ref, 'refs/tags/')
296
+ runs-on : ubuntu-latest
297
+ needs : [ check-version ]
298
+ permissions :
299
+ contents : write
300
+ steps :
279
301
- name : Download artifacts
280
302
uses : actions/download-artifact@v4
281
303
with :
304
+ pattern : objdiff-*
282
305
path : artifacts
283
306
- name : Rename artifacts
284
307
working-directory : artifacts
@@ -308,3 +331,53 @@ jobs:
308
331
files : out/*
309
332
draft : true
310
333
generate_release_notes : true
334
+
335
+ release-cargo :
336
+ name : Release (Cargo)
337
+ if : startsWith(github.ref, 'refs/tags/')
338
+ runs-on : ubuntu-latest
339
+ needs : [ check-version ]
340
+ steps :
341
+ - name : Checkout
342
+ uses : actions/checkout@v4
343
+ - name : Setup Rust toolchain
344
+ uses : dtolnay/rust-toolchain@stable
345
+ - name : Publish
346
+ env :
347
+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
348
+ run : cargo publish -p objdiff-core --dry-run
349
+
350
+ release-npm :
351
+ name : Release (npm)
352
+ if : startsWith(github.ref, 'refs/tags/')
353
+ runs-on : ubuntu-latest
354
+ needs : [ check-version ]
355
+ steps :
356
+ - name : Checkout
357
+ uses : actions/checkout@v4
358
+ - name : Setup Node
359
+ uses : actions/setup-node@v4
360
+ with :
361
+ node-version : lts/*
362
+ registry-url : ' https://registry.npmjs.org'
363
+ - name : Download artifacts
364
+ uses : actions/download-artifact@v4
365
+ with :
366
+ name : wasm
367
+ path : objdiff-wasm/dist
368
+ - name : Publish
369
+ working-directory : objdiff-wasm
370
+ env :
371
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
372
+ run : |
373
+ set -euo pipefail
374
+ version=$(jq -r '.version' package.json)
375
+ tag="latest"
376
+ # Check for prerelease by looking for a dash
377
+ case "$version" in
378
+ *-*)
379
+ tag=$(echo "$version" | sed -e 's/^[^-]*-//' -e 's/\..*$//')
380
+ ;;
381
+ esac
382
+ echo "Publishing version $version with tag '$tag'..."
383
+ npm publish --provenance --access public --tag "$tag" --dry-run
0 commit comments