Skip to content

Publish Node SDK

Publish Node SDK #2

Workflow file for this run

name: Publish Node SDK
on:
workflow_call:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: aarch64-apple-darwin
- host: macos-latest
target: x86_64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
zig: true
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
zig: true
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
zig: true
- host: windows-latest
target: x86_64-pc-windows-msvc
name: Build ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup workspace context
shell: bash
run: bash .github/setup-workspace.sh
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- name: Install protobuf compiler
shell: bash
run: |
if [ "${{ matrix.settings.host }}" = "ubuntu-latest" ]; then
sudo apt-get update && sudo apt-get install -y protobuf-compiler
elif [ "${{ matrix.settings.host }}" = "windows-latest" ]; then
choco install protoc -y
else
brew install protobuf
fi
- name: Install Zig
if: matrix.settings.zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- name: Install dependencies
working-directory: sdk/node
run: npm install
- name: Build native module
working-directory: sdk/node
shell: bash
run: |
if [ "${{ matrix.settings.zig }}" = "true" ]; then
npx napi build --platform --release --target ${{ matrix.settings.target }} --zig
else
npx napi build --platform --release --target ${{ matrix.settings.target }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: node-bindings-${{ matrix.settings.target }}
path: sdk/node/*.node
if-no-files-found: error
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- name: Install dependencies
working-directory: sdk/node
run: npm install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: node-bindings-*
path: sdk/node/artifacts
merge-multiple: true
- name: Move artifacts
working-directory: sdk/node
run: |
mv artifacts/*.node . 2>/dev/null || true
ls -la *.node
- name: Prepublish (generate optionalDependencies)
working-directory: sdk/node
run: npx napi prepublish -t npm
- name: Publish to npm
working-directory: sdk/node
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --ignore-scripts || true