164 lines
5.8 KiB
YAML
164 lines
5.8 KiB
YAML
name: RuvLLM Native Build
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'ruvllm-v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
publish:
|
|
description: 'Publish to npm'
|
|
required: false
|
|
default: 'false'
|
|
type: boolean
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
node_file: ruvllm.linux-x64-gnu.node
|
|
npm_package: ruvllm-linux-x64-gnu
|
|
- target: aarch64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
node_file: ruvllm.linux-arm64-gnu.node
|
|
npm_package: ruvllm-linux-arm64-gnu
|
|
- target: x86_64-apple-darwin
|
|
os: macos-13
|
|
node_file: ruvllm.darwin-x64.node
|
|
npm_package: ruvllm-darwin-x64
|
|
- target: aarch64-apple-darwin
|
|
os: macos-14
|
|
node_file: ruvllm.darwin-arm64.node
|
|
npm_package: ruvllm-darwin-arm64
|
|
- target: x86_64-pc-windows-msvc
|
|
os: windows-latest
|
|
node_file: ruvllm.win32-x64-msvc.node
|
|
npm_package: ruvllm-win32-x64-msvc
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
name: Build ${{ matrix.target }}
|
|
|
|
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 Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Install napi-rs CLI
|
|
run: npm install -g @napi-rs/cli
|
|
|
|
- name: Install cross-compilation tools (Linux ARM64)
|
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
|
|
|
- name: Setup cross-compilation env (Linux ARM64)
|
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
|
|
|
|
- name: Build native library with napi
|
|
shell: bash
|
|
run: |
|
|
cd examples/ruvLLM
|
|
# Use cargo directly with --lib to avoid building binaries
|
|
cargo build --release --lib --features napi --target ${{ matrix.target }}
|
|
# napi artifacts command to copy the output
|
|
napi artifacts --build-output-dir ../../target/${{ matrix.target }}/release || true
|
|
|
|
- name: Copy artifact (Unix)
|
|
if: runner.os != 'Windows'
|
|
shell: bash
|
|
run: |
|
|
mkdir -p npm/packages/${{ matrix.npm_package }}
|
|
# Try napi output first, then cargo output
|
|
if ls examples/ruvLLM/*.node 1>/dev/null 2>&1; then
|
|
cp examples/ruvLLM/*.node npm/packages/${{ matrix.npm_package }}/${{ matrix.node_file }}
|
|
elif [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ] || [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
|
|
cp target/${{ matrix.target }}/release/libruvllm.so npm/packages/${{ matrix.npm_package }}/${{ matrix.node_file }}
|
|
else
|
|
cp target/${{ matrix.target }}/release/libruvllm.dylib npm/packages/${{ matrix.npm_package }}/${{ matrix.node_file }}
|
|
fi
|
|
|
|
- name: Copy artifact (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -ItemType Directory -Force -Path npm/packages/${{ matrix.npm_package }}
|
|
# Try napi output first, then cargo output
|
|
if (Test-Path examples/ruvLLM/*.node) {
|
|
Copy-Item examples/ruvLLM/*.node npm/packages/${{ matrix.npm_package }}/${{ matrix.node_file }}
|
|
} else {
|
|
Copy-Item target/${{ matrix.target }}/release/ruvllm.dll npm/packages/${{ matrix.npm_package }}/${{ matrix.node_file }}
|
|
}
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.npm_package }}
|
|
path: npm/packages/${{ matrix.npm_package }}/${{ matrix.node_file }}
|
|
|
|
publish:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/ruvllm-v') || github.event.inputs.publish == 'true'
|
|
|
|
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: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Copy artifacts to packages
|
|
run: |
|
|
cp artifacts/ruvllm-linux-x64-gnu/ruvllm.linux-x64-gnu.node npm/packages/ruvllm-linux-x64-gnu/
|
|
cp artifacts/ruvllm-linux-arm64-gnu/ruvllm.linux-arm64-gnu.node npm/packages/ruvllm-linux-arm64-gnu/
|
|
cp artifacts/ruvllm-darwin-x64/ruvllm.darwin-x64.node npm/packages/ruvllm-darwin-x64/
|
|
cp artifacts/ruvllm-darwin-arm64/ruvllm.darwin-arm64.node npm/packages/ruvllm-darwin-arm64/
|
|
cp artifacts/ruvllm-win32-x64-msvc/ruvllm.win32-x64-msvc.node npm/packages/ruvllm-win32-x64-msvc/
|
|
|
|
- name: Publish platform packages
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
for pkg in ruvllm-linux-x64-gnu ruvllm-linux-arm64-gnu ruvllm-darwin-x64 ruvllm-darwin-arm64 ruvllm-win32-x64-msvc; do
|
|
cd npm/packages/$pkg
|
|
npm publish --access public || true
|
|
cd ../../..
|
|
done
|
|
|
|
- name: Build and publish main package
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
cd npm/packages/ruvllm
|
|
npm install
|
|
npm run build
|
|
npm publish --access public || true
|