-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (105 loc) · 3.43 KB
/
Copy pathreusable-native-build.yml
File metadata and controls
119 lines (105 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
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: Setup Zig
if: contains(inputs.target, 'musl')
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1
with:
version: 0.14.1
- name: Install cargo-zigbuild
if: contains(inputs.target, 'musl')
uses: taiki-e/install-action@6c6fd71fe4fb72c3697d269963d0e15df8adedad # v2.85.10
with:
tool: cargo-zigbuild@0.23.0
- name: Install RISC-V GNU toolchain
if: inputs.target == 'riscv64gc-unknown-linux-gnu'
shell: bash
run: |
sudo apt-get update
sudo apt-get install --yes gcc-riscv64-linux-gnu
- name: Build native binding
shell: bash
working-directory: packages/rstack
run: |
args=(
build
--config-path napi.json
--platform
--release
--target "$RUST_TARGET"
--manifest-path ../../Cargo.toml
--package rstack-binding
--output-dir .
--js binding.cjs
--dts binding.d.cts
)
case "$RUST_TARGET" in
x86_64-unknown-linux-gnu | aarch64-unknown-linux-gnu | \
powerpc64le-unknown-linux-gnu | s390x-unknown-linux-gnu)
args+=(--use-napi-cross)
;;
x86_64-unknown-linux-musl | aarch64-unknown-linux-musl | \
riscv64gc-unknown-linux-musl)
args+=(--cross-compile)
;;
aarch64-apple-darwin | x86_64-apple-darwin)
export MACOSX_DEPLOYMENT_TARGET=11.0
;;
i686-pc-windows-msvc)
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=32
export CARGO_PROFILE_RELEASE_LTO=false
;;
riscv64gc-unknown-linux-gnu | x86_64-pc-windows-msvc | \
aarch64-pc-windows-msvc)
;;
*)
echo "Unsupported native target: $RUST_TARGET" >&2
exit 1
;;
esac
pnpm exec napi "${args[@]}"
- 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