Skip to content

feat: napi support

feat: napi support #1

Workflow file for this run

name: windows-napi
# NOTE: `paths` filters deliberately do NOT accompany the tag trigger — a tag push can have an
# empty changed-file set, and paths+tags together silently skip the run.
on:
push:
tags:
- 'windows-napi-v*'
pull_request:
paths:
- 'windows-napi/**'
- 'runtime/**'
- 'metadata/**'
- '.github/workflows/windows-napi.yml'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-pc-windows-msvc
- target: aarch64-pc-windows-msvc
name: build ${{ matrix.settings.target }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.settings.target }}
- name: Install npm dependencies
working-directory: windows-napi
run: npm ci
- name: Build .node
working-directory: windows-napi
run: npx napi build --platform --release --target ${{ matrix.settings.target }}
- name: Run test suite (x64 only — the runner cannot execute arm64 binaries)
if: matrix.settings.target == 'x86_64-pc-windows-msvc'
working-directory: windows-napi
# Server runner SKUs can lack optional feature packs some suites touch (e.g. Media
# Foundation for the MediaPlayer event test), so failures here warn instead of block;
# the authoritative run is the local one on a client SKU.
continue-on-error: true
run: npm test
- uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: windows-napi/windows.*.node
if-no-files-found: error
publish:
name: publish to npm
if: startsWith(github.ref, 'refs/tags/windows-napi-v')
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- name: Install npm dependencies
working-directory: windows-napi
run: npm ci
- name: Download all binding artifacts
uses: actions/download-artifact@v4
with:
path: windows-napi/artifacts
- name: Distribute artifacts into npm/<triple> sub-packages
working-directory: windows-napi
run: npx napi artifacts
- name: Publish
working-directory: windows-napi
# `napi prepublish` (prepublishOnly script) publishes each npm/<triple> sub-package,
# then the root package publishes with them as optionalDependencies.
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}