-
Notifications
You must be signed in to change notification settings - Fork 2
402 lines (386 loc) · 12.7 KB
/
ci.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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
name: CI
on:
push:
workflow_dispatch:
inputs:
npm-package-version:
description: Specify the package.json npm package version, e.g. `0.0.1-alpha.0`
required: true
npm-package-tag:
description: Specify the tag to be used for npm publish, e.g. `latest`, `beta`, `alpha`
required: true
jobs:
cancel-previous-runs:
runs-on: ubuntu-22.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build_linux-x64-musl:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: Download x86_64-linux-musl-cross toolchain
run: curl -O -C - https://musl.cc/x86_64-linux-musl-cross.tgz
- name: Install x86_64-linux-musl-cross toolchain
run: tar xf x86_64-linux-musl-cross.tgz
- name: Configure linux-x64-musl cross compile
run: |
echo "CC_x86_64_unknown_linux_musl=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc" >> $GITHUB_ENV
echo "CXX_x86_64_unknown_linux_musl=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl--g++" >> $GITHUB_ENV
echo "AR_x86_64_unknown_linux_musl=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-ar" >> $GITHUB_ENV
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_AR=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-ar" >> $GITHUB_ENV
echo "TARGET_PLATFORM=linux" >> $GITHUB_ENV
echo "TARGET_ARCH=x64" >> $GITHUB_ENV
echo "TARGET_LIBC=musl" >> $GITHUB_ENV
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: linux-x64-musl
path: native/linux-x64-musl.node
if-no-files-found: error
build_linux-arm64-musl:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-musl
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: Download aarch64-linux-musl-cross toolchain
run: curl -O -C - https://musl.cc/aarch64-linux-musl-cross.tgz
- name: Install aarch64-linux-musl-cross toolchain
run: tar xf aarch64-linux-musl-cross.tgz
- name: Configure linux-arm64-musl cross compile
run: |
echo "CC_aarch64_unknown_linux_musl=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_musl=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl--g++" >> $GITHUB_ENV
echo "AR_aarch64_unknown_linux_musl=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-ar" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_AR=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-ar" >> $GITHUB_ENV
echo "TARGET_PLATFORM=linux" >> $GITHUB_ENV
echo "TARGET_ARCH=arm64" >> $GITHUB_ENV
echo "TARGET_LIBC=musl" >> $GITHUB_ENV
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: linux-arm64-musl
path: native/linux-arm64-musl.node
if-no-files-found: error
build_linux-x64-glibc:
runs-on: ubuntu-22.04
container:
image: rust:buster
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: linux-x64-glibc
path: native/linux-x64-glibc.node
if-no-files-found: error
build_linux-arm64-glibc:
runs-on: ubuntu-22.04
container:
image: rust:buster
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: Install cross compile deps
run: |
apt-get update && apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross gcc-aarch64-linux-gnu qemu-user
- name: Configure linux-arm64 cross compile
run: |
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu"' >> $GITHUB_ENV
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
echo "TARGET_ARCH=arm64" >> $GITHUB_ENV
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: linux-arm64-glibc
path: native/linux-arm64-glibc.node
if-no-files-found: error
build_win-x64:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: win32-x64
path: native/win32-x64.node
if-no-files-found: error
build_darwin-x64:
runs-on: macos-14
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: darwin-x64
path: native/darwin-x64.node
if-no-files-found: error
build_darwin-arm64:
runs-on: macos-14
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: Swatinem/rust-cache@v2
- name: Configure macos-arm64 cross compile
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
echo "TARGET_ARCH=arm64" >> $GITHUB_ENV
- name: npm i
run: npm i
- name: Build
run: npm run build:cargo
- uses: actions/upload-artifact@v3
with:
name: darwin-arm64
path: native/darwin-arm64.node
if-no-files-found: error
test_linux-arm64-glibc:
runs-on: ubuntu-22.04
needs:
- build_linux-arm64-glibc
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: linux-arm64-glibc
path: native
- name: npm i
run: npm i
- name: Build js
run: npm run build:ts
- uses: uraimo/run-on-arch-action@v2
name: Run on arch
with:
arch: aarch64
distro: ubuntu_latest
githubToken: ${{ github.token }}
install: |
apt-get update && apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y --no-install-recommends nodejs
run: |
npm run test:js
test_linux-arm64-musl:
runs-on: ubuntu-22.04
needs:
- build_linux-arm64-musl
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: linux-arm64-musl
path: native
- name: npm i
run: npm i
- name: Build js
run: npm run build:ts
- uses: uraimo/run-on-arch-action@v2
name: Run on arch
with:
arch: aarch64
distro: alpine_latest
githubToken: ${{ github.token }}
install: |
apk add nodejs npm
run: |
npm run test:js
test_linux-x64-glibc:
runs-on: ubuntu-22.04
container:
image: node:16-bullseye
needs:
- build_linux-x64-glibc
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: linux-x64-glibc
path: native
- name: npm i
run: npm i
- name: Build js
run: npm run build:ts
- name: Test js
run: npm run test:js
- name: Test examples
working-directory: examples
run: npm i && npm test
test_linux-x64-musl:
runs-on: ubuntu-22.04
container:
image: node:16-alpine
needs:
- build_linux-x64-musl
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: linux-x64-musl
path: native
- name: npm i
run: npm i
- name: Build js
run: npm run build:ts
- name: Test js
run: npm run test:js
- name: Test examples
working-directory: examples
run: npm i && npm test
test_win-x64:
runs-on: windows-2022
needs:
- build_win-x64
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: win32-x64
path: native
- name: npm i
run: npm i
- name: Build js
run: npm run build:ts
- name: Test js
run: npm run test:js
- name: Test examples
working-directory: examples
run: npm i && npm test
test_darwin-x64:
runs-on: macos-14
needs:
- build_darwin-x64
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: darwin-x64
path: native
- name: npm i
run: npm i
- name: Build js
run: npm run build:ts
- name: Test js
run: npm run test:js
- name: Test examples
working-directory: examples
run: npm i && npm test
npm-package:
runs-on: ubuntu-22.04
needs:
- build_linux-x64-musl
- build_linux-arm64-musl
- build_linux-x64-glibc
- build_linux-arm64-glibc
- build_win-x64
- build_darwin-x64
- build_darwin-arm64
env:
NPM_PACKAGE_VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.npm-package-version || '0.0.1-alpha.0' }}
NPM_PACKAGE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.npm-package-tag || 'alpha' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: https://registry.npmjs.org
always-auth: true
- uses: actions/download-artifact@v3
with:
path: native
- name: Position downloaded artifacts
run: |
mkdir -p ./native
find ./native -mindepth 2 -type f -exec mv -t ./native -i '{}' +
find ./native -mindepth 1 -type d -empty -delete
ls -R ./native
- name: npm version
run: npm version --git-tag-version=false --allow-same-version $NPM_PACKAGE_VERSION
- name: npm build
run: |
npm i
npm run build:ts
- name: npm pack
run: |
npm pack
mv "stacks-encoding-native-js-$NPM_PACKAGE_VERSION.tgz" "stacks-encoding-native-js.tgz"
- uses: actions/upload-artifact@v3
with:
name: stacks-encoding-native-js.tgz
path: stacks-encoding-native-js.tgz
if-no-files-found: error
- name: Publish npm package
if: github.event_name == 'workflow_dispatch'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish stacks-encoding-native-js.tgz --tag $NPM_PACKAGE_TAG --access public