-
Notifications
You must be signed in to change notification settings - Fork 5
110 lines (97 loc) · 3.45 KB
/
build-native.yml
File metadata and controls
110 lines (97 loc) · 3.45 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
name: Build Native
on:
pull_request:
paths:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
workflow_dispatch:
permissions: {}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
node_arch: x64
node_os: linux
artifact_key: linux-x64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
node_arch: arm64
node_os: linux
artifact_key: linux-arm64
cross: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
node_arch: x64
node_os: linux
artifact_key: linux-x64-musl
cross: true
- os: macos-latest
target: aarch64-apple-darwin
node_arch: arm64
node_os: darwin
artifact_key: darwin-arm64
- os: macos-14
target: x86_64-apple-darwin
node_arch: x64
node_os: darwin
artifact_key: darwin-x64
- os: windows-latest
target: x86_64-pc-windows-msvc
node_arch: x64
node_os: win32
artifact_key: win32-x64
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.target }}
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: crates/codegraph-core
- name: Install cross-compilation tools (aarch64-gnu)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
- name: Install cross-compilation tools (x86_64-musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
# Create linker script so -lgcc_s resolves to static libgcc
MUSL_LIB_DIR="$(dirname "$(musl-gcc -print-libgcc-file-name)")"
echo 'INPUT(-lgcc)' | sudo tee "${MUSL_LIB_DIR}/libgcc_s.so" > /dev/null
echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> "$GITHUB_ENV"
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> "$GITHUB_ENV"
# Symlink libgcc_s into Rust sysroot so rust-lld can find it for host builds
GNU_LIB="$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/lib"
sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so"
sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so.1"
- name: Install napi-rs CLI
run: npm install -g @napi-rs/cli@3
- name: Build native addon
working-directory: crates/codegraph-core
run: napi build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: native-${{ matrix.artifact_key }}
path: crates/codegraph-core/*.node
if-no-files-found: error