Build Native Binaries #22
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: Build Native Binaries | |
on: | |
workflow_dispatch: # Trigger manually from Actions tab | |
push: | |
tags: | |
- "v*" # OR when you push a version tag like `v1.0.0` | |
jobs: | |
build: | |
name: Build ${{ matrix.os }} ${{ matrix.arch }} Node.js ${{ matrix.node-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
arch: [x64] | |
node-version: [18, 19, 20, 21, 22, 23, 24] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix['node-version'] }} | |
- name: Install build dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential python3 | |
- name: Install dependencies | |
run: npm ci --ignore-scripts | |
- name: Build native addon and copy to lib | |
run: | | |
node-gyp clean | |
node-gyp configure | |
node-gyp build | |
node ./copy.js | |
- name: Package native binary | |
run: npm run package | |
- name: Upload to GitHub Release | |
env: | |
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Publishing to GitHub Release..." | |
npx node-pre-gyp-github publish --release |