-
Notifications
You must be signed in to change notification settings - Fork 4.8k
92 lines (90 loc) · 3.3 KB
/
build-rust-binding.yml
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
name: Build Rust Binaries
on:
workflow_call:
inputs:
name:
description: 'The name of the binary to build'
required: false
default: 'taro'
type: string
jobs:
build:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
settings:
- host: macos-12
target: x86_64-apple-darwin
build: |
pnpm build:binding:release
strip -x crates/native_binding/*.node
- host: windows-latest
build: pnpm build:binding:release
target: x86_64-pc-windows-msvc
- host: ubuntu-20.04
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: |-
set -e &&
pnpm build:binding:release --target x86_64-unknown-linux-gnu &&
strip crates/native_binding/*.node
- host: ubuntu-20.04
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: set -e && pnpm build:binding:release && strip crates/native_binding/*.node
- host: macos-12
target: aarch64-apple-darwin
build: |
pnpm build:binding:release --target aarch64-apple-darwin
strip -x crates/native_binding/*.node
name: stable - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 9
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- name: Install dependencies
run: pnpm install --filter @tarojs/binding... --frozen-lockfile
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: ${{ matrix.settings.build }}
- name: Build
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: crates/native_binding/${{ inputs.name }}.*.node
if-no-files-found: error