Require Node.js >= 22 (V8 API compatibility) #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| push: | |
| tags: ['v*'] | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: npm run build -- --target aarch64-apple-darwin | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: npm run build -- --target x86_64-apple-darwin | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: npm run build -- --target x86_64-unknown-linux-gnu | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| build: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc | |
| export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ | |
| export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
| npm run build -- --target aarch64-unknown-linux-gnu | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| build: npm run build -- --target x86_64-pc-windows-msvc | |
| name: Build - ${{ matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.settings.target }} | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build native addon | |
| run: ${{ matrix.settings.build }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: '*.node' | |
| if-no-files-found: error | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Move artifacts | |
| run: | | |
| for dir in artifacts/bindings-*/; do | |
| cp "$dir"*.node . | |
| done | |
| ls -la *.node | |
| - name: Generate npm packages | |
| run: npx napi prepublish -t npm | |
| - name: Publish platform packages | |
| run: | | |
| for pkg in npm/*/; do | |
| if [ -f "$pkg/package.json" ]; then | |
| echo "Publishing $pkg..." | |
| npm publish "$pkg" --access public --provenance || true | |
| fi | |
| done | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish main package | |
| run: npm publish --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: '*.node' |