Build Native Binaries #18
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, 20, 22] | |
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 and build | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH | |
fi | |
npm install | |
npm run build | |
- 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 |