Skip to content

Commit 65ad88a

Browse files
committed
refactor: 🎨 update linux musl to zig build
1 parent c7bc169 commit 65ad88a

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Zigbuild
2+
3+
description: Build a musl target using cargo-zigbuild (avoids Docker with outdated Node.js)
4+
5+
inputs:
6+
target:
7+
required: true
8+
type: string
9+
profile:
10+
default: "release"
11+
required: false
12+
type: string
13+
zig-version:
14+
default: "0.14.1"
15+
required: false
16+
type: string
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Setup Rust Target
22+
shell: bash
23+
run: rustup target add ${{ inputs.target }}
24+
25+
- name: Setup Zig
26+
uses: mlugg/setup-zig@v2
27+
with:
28+
version: ${{ inputs.zig-version }}
29+
30+
- name: Install cargo-zigbuild
31+
uses: taiki-e/install-action@v2
32+
env:
33+
GITHUB_TOKEN: ${{ github.token }}
34+
with:
35+
tool: cargo-zigbuild
36+
37+
- name: Build ${{ inputs.target }}
38+
shell: bash
39+
run: RUST_TARGET=${{ inputs.target }} pnpm build:binding:${{ inputs.profile }} --target ${{ inputs.target }} -x

‎.github/workflows/reusable-build.yml‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,21 @@ jobs:
8989
pre: |
9090
export CC_aarch64_unknown_linux_gnu=clang
9191
92-
- name: Build x86_64-unknown-linux-musl in Docker
92+
- name: Build x86_64-unknown-linux-musl with zigbuild
9393
if: ${{ inputs.target == 'x86_64-unknown-linux-musl' }}
94-
uses: ./.github/actions/docker-build
94+
uses: ./.github/actions/zigbuild
9595
with:
9696
target: ${{ inputs.target }}
97-
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
9897
profile: ${{ inputs.profile }}
99-
pre: |
100-
# musl will enable clang-sys static linking
101-
# https://github.com/KyleMayes/clang-sys?tab=readme-ov-file#static
10298

103-
- name: Build aarch64-unknown-linux-musl in Docker
99+
- name: Build aarch64-unknown-linux-musl with zigbuild
104100
if: ${{ inputs.target == 'aarch64-unknown-linux-musl' }}
105-
uses: ./.github/actions/docker-build
101+
uses: ./.github/actions/zigbuild
106102
with:
107103
target: ${{ inputs.target }}
108-
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
109104
profile: ${{ inputs.profile }}
110-
pre: |
111-
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc
112-
# musl will enable clang-sys static linking
113-
# https://github.com/KyleMayes/clang-sys?tab=readme-ov-file#static
114105

115-
# setup rust target for native runner
106+
# setup rust target for native runner (non-linux)
116107
- name: Setup Rust Target
117108
if: ${{ !contains(inputs.target, 'linux') }}
118109
run: rustup target add ${{ inputs.target }}

0 commit comments

Comments
 (0)