Skip to content

Commit fd9f2ef

Browse files
committed
ci(release): exercise every native addon before publish
1 parent 0f20361 commit fd9f2ef

1 file changed

Lines changed: 90 additions & 13 deletions

File tree

.github/workflows/publish.yml

Lines changed: 90 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,35 +274,35 @@ jobs:
274274
matrix:
275275
include:
276276
- target: x86_64-unknown-linux-gnu
277-
runner: ubuntu-latest
278-
cross: "true"
277+
runner: ubuntu-24.04
278+
cross: "false"
279279
addon: linux-x64-gnu
280280
- target: aarch64-unknown-linux-gnu
281-
runner: ubuntu-latest
282-
cross: "true"
281+
runner: ubuntu-24.04-arm
282+
cross: "false"
283283
addon: linux-arm64-gnu
284284
- target: x86_64-unknown-linux-musl
285-
runner: ubuntu-latest
285+
runner: ubuntu-24.04
286286
cross: "true"
287287
addon: linux-x64-musl
288288
- target: aarch64-unknown-linux-musl
289-
runner: ubuntu-latest
289+
runner: ubuntu-24.04-arm
290290
cross: "true"
291291
addon: linux-arm64-musl
292292
- target: x86_64-apple-darwin
293-
runner: macos-latest
293+
runner: macos-15-intel
294294
cross: "false"
295295
addon: darwin-x64
296296
- target: aarch64-apple-darwin
297-
runner: macos-latest
297+
runner: macos-15
298298
cross: "false"
299299
addon: darwin-arm64
300300
- target: x86_64-pc-windows-msvc
301-
runner: windows-latest
301+
runner: windows-2025
302302
cross: "false"
303303
addon: win32-x64-msvc
304304
- target: aarch64-pc-windows-msvc
305-
runner: windows-latest
305+
runner: windows-11-arm
306306
cross: "false"
307307
addon: win32-arm64-msvc
308308
runs-on: ${{ matrix.runner }}
@@ -343,14 +343,14 @@ jobs:
343343
test "$(rustc --version)" = "rustc 1.97.1 (8bab26f4f 2026-07-14)"
344344
345345
- name: Install checksum-verified Zig for Linux cross-compilation
346-
if: matrix.runner == 'ubuntu-latest' && matrix.cross == 'true'
346+
if: matrix.cross == 'true'
347347
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1
348348
with:
349349
version: 0.16.0
350350
use-cache: false
351351

352352
- name: Install Linux cross-compilation tooling
353-
if: matrix.runner == 'ubuntu-latest' && matrix.cross == 'true'
353+
if: matrix.cross == 'true'
354354
shell: bash
355355
run: |
356356
set -euo pipefail
@@ -362,6 +362,12 @@ jobs:
362362
shell: bash
363363
run: pnpm install --frozen-lockfile
364364

365+
- name: Download verified main package
366+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
367+
with:
368+
name: release
369+
path: .release-native-main
370+
365371
- name: Build native addon for ${{ matrix.target }}
366372
shell: bash
367373
env:
@@ -389,6 +395,77 @@ jobs:
389395
console.log('produced:', regular[0]);
390396
"
391397
398+
- name: Pack, install, and exercise ${{ matrix.addon }}
399+
shell: bash
400+
run: |
401+
set -euo pipefail
402+
dir="${{ matrix.addon }}"
403+
expected="zodrs_node.$dir.node"
404+
package_dir="packages/zodrs/npm/$dir"
405+
verify_root=".release-native-verify"
406+
cleanup() {
407+
rm -rf "$verify_root"
408+
rm -f "$package_dir/$expected"
409+
}
410+
trap cleanup EXIT
411+
rm -rf "$verify_root"
412+
mkdir -p "$verify_root/platform"
413+
rm -f "$package_dir/"*.node
414+
cp "packages/zodrs/native/$expected" "$package_dir/$expected"
415+
416+
platform_tarball=$(cd "$package_dir" && npm pack --ignore-scripts)
417+
test -f "$package_dir/$platform_tarball"
418+
mv "$package_dir/$platform_tarball" "$verify_root/platform/$platform_tarball"
419+
420+
metadata=".release-native-main/release-metadata.json"
421+
main_tarball_name=$(node -e '
422+
const fs = require("fs");
423+
const metadata = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
424+
if (typeof metadata.npm_tarball_name !== "string") process.exit(1);
425+
process.stdout.write(metadata.npm_tarball_name);
426+
' "$metadata")
427+
main_tarball=".release-native-main/$main_tarball_name"
428+
test -f "$main_tarball"
429+
cp "$main_tarball" "$verify_root/main.tgz"
430+
431+
if [[ "$dir" == *-musl ]]; then
432+
case "$dir" in
433+
*-arm64-*) expected_arch=arm64 ;;
434+
*) expected_arch=x64 ;;
435+
esac
436+
docker run --rm \
437+
-e ADDON_DIR="$dir" \
438+
-e EXPECTED_ARCH="$expected_arch" \
439+
-e PLATFORM_TARBALL="$platform_tarball" \
440+
-v "$PWD:/work" \
441+
-w /work \
442+
node:24-alpine \
443+
sh -euc '
444+
test "$(node -p "process.platform")" = linux
445+
test "$(node -p "process.arch")" = "$EXPECTED_ARCH"
446+
npm install --global npm@12.0.2
447+
test "$(npm --version)" = 12.0.2
448+
install_root=.release-native-verify/install
449+
mkdir -p "$install_root"
450+
printf "{\"private\":true}\n" > "$install_root/package.json"
451+
npm install --prefix "$install_root" --ignore-scripts --no-audit --no-fund \
452+
.release-native-verify/main.tgz \
453+
".release-native-verify/platform/$PLATFORM_TARBALL"
454+
node packages/zodrs/scripts/verify-installed.mjs \
455+
"$install_root/node_modules/zod-rs" native \
456+
packages/zodrs "packages/zodrs/npm/$ADDON_DIR"
457+
'
458+
else
459+
install_root="$verify_root/install"
460+
mkdir -p "$install_root"
461+
printf '{"private":true}\n' > "$install_root/package.json"
462+
npm install --prefix "$install_root" --ignore-scripts --no-audit --no-fund \
463+
"$verify_root/main.tgz" "$verify_root/platform/$platform_tarball"
464+
node packages/zodrs/scripts/verify-installed.mjs \
465+
"$install_root/node_modules/zod-rs" native \
466+
packages/zodrs "$package_dir"
467+
fi
468+
392469
- name: Upload native artifact
393470
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
394471
with:
@@ -781,7 +858,7 @@ jobs:
781858
- name: Obtain temporary crates.io token
782859
if: steps.classify.outputs.crate_state == 'missing'
783860
id: crates-auth
784-
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
861+
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d6b1a18 # v1.0.5
785862

786863
- name: Publish and verify crate
787864
if: steps.classify.outputs.crate_state == 'missing'

0 commit comments

Comments
 (0)