Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/reusable-native-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Reusable Native Build

on:
workflow_call:
inputs:
target:
description: Rust target triple to build
required: true
type: string
runner:
description: GitHub-hosted runner label
required: true
type: string
filename:
description: Expected NAPI-RS binary filename
required: true
type: string
use_napi_cross:
description: Build with the NAPI-RS cross toolchain
default: false
required: false
type: boolean

permissions:
contents: read

env:
CARGO_INCREMENTAL: 0

jobs:
build:
name: Build ${{ inputs.target }}
runs-on: ${{ inputs.runner }}
env:
RUST_TARGET: ${{ inputs.target }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 24.18.0
package-manager-cache: false

- name: Install Pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
with:
run_install: true

- name: Install Rust target
shell: bash
run: rustup target add "$RUST_TARGET"

- name: Build native binding with NAPI-RS cross toolchain
if: inputs.use_napi_cross
shell: bash
working-directory: packages/rstack
run: >-
pnpm exec napi build --platform --release
--target "$RUST_TARGET"
--manifest-path ../../Cargo.toml
--package rstack-binding
--package-json-path package.json
--output-dir .
--js binding.cjs
--dts binding.d.cts
--use-napi-cross
Comment thread
chenjiahan marked this conversation as resolved.

- name: Build native binding
if: ${{ !inputs.use_napi_cross }}
shell: bash
working-directory: packages/rstack
run: >-
pnpm exec napi build --platform --release
--target "$RUST_TARGET"
--manifest-path ../../Cargo.toml
--package rstack-binding
--package-json-path package.json
--output-dir .
--js binding.cjs
--dts binding.d.cts

- name: Upload native binding
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: native-${{ inputs.target }}
path: packages/rstack/${{ inputs.filename }}
if-no-files-found: error
retention-days: 1
4 changes: 3 additions & 1 deletion packages/rstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
"napi": {
"binaryName": "rstack",
"packageName": "@rstackjs/binding",
"targets": []
"targets": [
"x86_64-unknown-linux-gnu"
]
}
}