-
-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (248 loc) · 8.4 KB
/
node.yml
File metadata and controls
255 lines (248 loc) · 8.4 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Node.js
env:
DEBUG: napi:*
ARTIFACT_PATH: bindings/node/rf24.*.node
MACOSX_DEPLOYMENT_TARGET: '10.13'
on:
push:
branches: [main]
tags: ['rf24-node/*']
paths:
- crates/**/*.rs
- bindings/node/**
- '!**/*.md'
- .github/workflows/node.yml
pull_request:
branches: [main]
paths:
- crates/**/*.rs
- bindings/node/**
- '!**/*.md'
- .github/workflows/node.yml
permissions: {}
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: yarn build --target x86_64-apple-darwin
- host: windows-latest
build: yarn build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: windows-latest
build: yarn build --target i686-pc-windows-msvc
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
build: yarn build --target x86_64-unknown-linux-musl -x
- host: macos-latest
target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: yarn build --target aarch64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
build: yarn build --target armv7-unknown-linux-gnueabihf --use-napi-cross
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
build: yarn build --target aarch64-unknown-linux-musl -x
- host: windows-latest
target: aarch64-pc-windows-msvc
build: yarn build --target aarch64-pc-windows-msvc
name: build ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 22
cache: ${{ !startsWith(github.ref, 'refs/tags/') && 'yarn' || '' }} # zizmor: ignore[cache-poisoning]
package-manager-cache: ${{ !startsWith(github.ref, 'refs/tags/') }} # zizmor: ignore[cache-poisoning]
- name: Setup Rust
run: |-
rustup update stable --no-self-update
rustup target add ${{ matrix.settings.target }}
- name: Cache cargo
if: ${{ !startsWith(github.ref, 'refs/tags') }}
uses: actions/cache@v5 # zizmor: ignore[cache-poisoning]
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.napi-rs
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.14.1
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@dc19f1e48450eefe5a29b8da6c6b00a87d730b37 # v1.18.1
if: ${{ contains(matrix.settings.target, 'musl') }}
- name: Install cargo-zigbuild
run: cargo binstall -y cargo-zigbuild
if: ${{ contains(matrix.settings.target, 'musl') }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: yarn install
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload native module as artifact
uses: actions/upload-artifact@v7
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.ARTIFACT_PATH }}
if-no-files-found: error
- name: Upload generated index.* as artifact
if: matrix.settings.target == 'armv7-unknown-linux-gnueabihf'
uses: actions/upload-artifact@v7
with:
name: generated-index
path: bindings/node/index.*
if-no-files-found: error
build-freebsd:
runs-on: ubuntu-latest
name: build FreeBSD
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Build
id: build
uses: cross-platform-actions/action@233156312992f3f169d8d0c633c21d12a5d30455 # v1.0.0
env:
DEBUG: napi:*
RUSTUP_IO_THREADS: 1
with:
operating_system: freebsd
version: '15.0'
memory: 8G
cpu_count: 3
environment_variables: DEBUG RUSTUP_IO_THREADS
shell: bash
run: |
sudo pkg install -y -f curl node libnghttp2 npm cmake
sudo npm install -g yarn --ignore-scripts
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain stable
source "$HOME/.cargo/env"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
echo "~~~~ yarn --version ~~~~"
yarn --version
pwd
ls -lah
whoami
env
freebsd-version
yarn install
yarn build
rm -rf node_modules
rm -rf target
rm -rf .yarn/cache
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-freebsd
path: ${{ env.ARTIFACT_PATH }}
if-no-files-found: error
universal-macOS:
name: Build universal macOS binary
needs:
- build
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 20
cache: ${{ !startsWith(github.ref, 'refs/tags/') && 'yarn' || '' }} # zizmor: ignore[cache-poisoning]
package-manager-cache: ${{ !startsWith(github.ref, 'refs/tags/') }} # zizmor: ignore[cache-poisoning]
- name: Install dependencies
run: yarn install
- name: Download macOS x64 artifact
uses: actions/download-artifact@v8
with:
name: bindings-x86_64-apple-darwin
path: bindings/node
- name: Download macOS arm64 artifact
uses: actions/download-artifact@v8
with:
name: bindings-aarch64-apple-darwin
path: bindings/node
- name: Combine binaries
run: yarn universal
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-universal-apple-darwin
path: ${{ env.ARTIFACT_PATH }}
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
# needed for trusted publishing
id-token: write
needs:
- build
- build-freebsd
- universal-macOS
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 24
cache: ${{ !startsWith(github.ref, 'refs/tags/') && 'yarn' || '' }} # zizmor: ignore[cache-poisoning]
package-manager-cache: ${{ !startsWith(github.ref, 'refs/tags/') }} # zizmor: ignore[cache-poisoning]
- name: Install dependencies
run: yarn install
- name: Download native artifacts
uses: actions/download-artifact@v8
with:
pattern: bindings-*
path: bindings/node/artifacts
- name: Download generated index artifact
uses: actions/download-artifact@v8
with:
name: generated-index
path: bindings/node
- name: Create npm dirs
working-directory: bindings/node
run: yarn napi create-npm-dirs
- name: Move artifacts
run: yarn artifacts
- name: List packages
run: ls -R ./bindings/node/npm
shell: bash
- run: yarn format:index
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
working-directory: bindings/node
run: npm publish