|
47 | 47 | publish-npm: |
48 | 48 | if: ${{ inputs.to_release == 'all' || inputs.to_release == 'npm' }} |
49 | 49 | name: ${{ inputs.dry_run == true && 'Dry Run - NPM Packages' || 'Publish NPM Packages' }} |
50 | | - needs: [build] |
| 50 | + needs: [build, napi-build] |
51 | 51 | runs-on: ubuntu-22.04 |
52 | 52 | environment: release |
53 | 53 | permissions: |
|
96 | 96 |
|
97 | 97 | - name: Move binaries |
98 | 98 | uses: ./.github/actions/move-artifacts |
| 99 | + # @rslint/native ships index.js (the napi loader) + index.d.ts, both |
| 100 | + # generated by `napi build` (gitignored). core's build:js dts bundle |
| 101 | + # also needs index.d.ts. The per-platform .node binaries ship in the |
| 102 | + # @rslint/native-{tuple} subpackages, populated from the napi-build |
| 103 | + # artifacts by move-artifacts above. |
| 104 | + - name: Setup Rust |
| 105 | + uses: ./.github/actions/setup-rust |
| 106 | + with: |
| 107 | + cache: 'false' |
| 108 | + - name: Build napi parser (index.js + index.d.ts) |
| 109 | + run: pnpm --filter @rslint/native build |
99 | 110 | - name: Build @rslint/core dist |
100 | 111 | run: pnpm --filter @rslint/core build:js |
101 | 112 | - name: Publish npm packages |
@@ -244,6 +255,15 @@ jobs: |
244 | 255 | - name: Format code |
245 | 256 | run: pnpm format:check |
246 | 257 |
|
| 258 | + # napi build produces index.d.ts (core build:js dts) + host .node |
| 259 | + # (runner tests at the Test step run the worker, which loads it). |
| 260 | + - name: Setup Rust |
| 261 | + uses: ./.github/actions/setup-rust |
| 262 | + with: |
| 263 | + cache: 'false' |
| 264 | + - name: Build napi parser (native) |
| 265 | + run: pnpm --filter @rslint/native build |
| 266 | + |
247 | 267 | - name: Build |
248 | 268 | run: pnpm run build |
249 | 269 |
|
@@ -315,12 +335,7 @@ jobs: |
315 | 335 | cache-name: ${{ matrix.node_os }}-${{ matrix.node_arch }} |
316 | 336 |
|
317 | 337 | - name: Setup Rust |
318 | | - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable |
319 | | - |
320 | | - - name: Cache Rust |
321 | | - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 |
322 | | - with: |
323 | | - cache-on-failure: true |
| 338 | + uses: ./.github/actions/setup-rust |
324 | 339 |
|
325 | 340 | - name: Install pnpm |
326 | 341 | run: corepack enable |
@@ -361,3 +376,87 @@ jobs: |
361 | 376 | with: |
362 | 377 | name: ${{ matrix.node_os }}-${{ matrix.node_arch }}-tsgo-built |
363 | 378 | path: typescript-go/built |
| 379 | + |
| 380 | + # napi `.node` parser binaries, one per target → the @rslint/native-{tuple} |
| 381 | + # subpackages. Separate matrix from the Go build job (which is ubuntu-only): |
| 382 | + # napi win32-msvc/darwin need native runners since zig and |
| 383 | + # @napi-rs/cross-toolchain can't target windows-msvc. Each leg uploads a |
| 384 | + # uniquely-named artifact (`native-{tuple}` — upload-artifact@v4 rejects |
| 385 | + # dupes); move-artifacts matches the `rslint.` filename prefix. gnu cross |
| 386 | + # legs use --use-napi-cross (@napi-rs/cross-toolchain, gnu-only); musl uses |
| 387 | + # -x (cargo-zigbuild) since cross-toolchain has no musl sysroot. |
| 388 | + napi-build: |
| 389 | + name: Build napi (${{ matrix.settings.target }}) |
| 390 | + strategy: |
| 391 | + fail-fast: false |
| 392 | + matrix: |
| 393 | + settings: |
| 394 | + - host: macos-latest |
| 395 | + target: aarch64-apple-darwin |
| 396 | + artifact: native-darwin-arm64 |
| 397 | + - host: macos-latest |
| 398 | + target: x86_64-apple-darwin |
| 399 | + artifact: native-darwin-x64 |
| 400 | + - host: windows-latest |
| 401 | + target: x86_64-pc-windows-msvc |
| 402 | + artifact: native-win32-x64-msvc |
| 403 | + - host: windows-latest |
| 404 | + target: aarch64-pc-windows-msvc |
| 405 | + artifact: native-win32-arm64-msvc |
| 406 | + - host: rspack-ubuntu-22.04-large |
| 407 | + target: x86_64-unknown-linux-gnu |
| 408 | + artifact: native-linux-x64-gnu |
| 409 | + - host: rspack-ubuntu-22.04-large |
| 410 | + target: aarch64-unknown-linux-gnu |
| 411 | + artifact: native-linux-arm64-gnu |
| 412 | + cross: '--use-napi-cross' |
| 413 | + - host: rspack-ubuntu-22.04-large |
| 414 | + target: x86_64-unknown-linux-musl |
| 415 | + artifact: native-linux-x64-musl |
| 416 | + cross: '-x' |
| 417 | + - host: rspack-ubuntu-22.04-large |
| 418 | + target: aarch64-unknown-linux-musl |
| 419 | + artifact: native-linux-arm64-musl |
| 420 | + cross: '-x' |
| 421 | + runs-on: ${{ matrix.settings.host }} |
| 422 | + steps: |
| 423 | + - name: Checkout |
| 424 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 425 | + with: |
| 426 | + fetch-depth: 1 |
| 427 | + ref: ${{ github.event.inputs.branch }} |
| 428 | + submodules: true |
| 429 | + |
| 430 | + - name: Setup Node.js |
| 431 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 |
| 432 | + with: |
| 433 | + node-version: '24' |
| 434 | + |
| 435 | + - name: Install pnpm |
| 436 | + run: corepack enable |
| 437 | + |
| 438 | + - name: Setup Rust |
| 439 | + uses: ./.github/actions/setup-rust |
| 440 | + with: |
| 441 | + targets: ${{ matrix.settings.target }} |
| 442 | + cache-key: ${{ matrix.settings.target }} |
| 443 | + |
| 444 | + - name: Install dependencies |
| 445 | + run: pnpm install --frozen-lockfile |
| 446 | + |
| 447 | + # musl legs cross-compile via cargo-zigbuild (napi -x); zig must be on |
| 448 | + # PATH (@napi-rs/cli auto-installs cargo-zigbuild when missing, but not |
| 449 | + # zig itself). |
| 450 | + - name: Setup zig (musl cross-compile) |
| 451 | + if: ${{ contains(matrix.settings.target, 'musl') }} |
| 452 | + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2 |
| 453 | + |
| 454 | + - name: Build napi |
| 455 | + run: pnpm --filter @rslint/native exec napi build --platform --release --target ${{ matrix.settings.target }} ${{ matrix.settings.cross || '' }} |
| 456 | + |
| 457 | + - name: Upload napi artifact |
| 458 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 459 | + with: |
| 460 | + name: ${{ matrix.settings.artifact }} |
| 461 | + path: crates/rslint-native/rslint.*.node |
| 462 | + if-no-files-found: error |
0 commit comments