-
Notifications
You must be signed in to change notification settings - Fork 6
238 lines (206 loc) · 7.32 KB
/
napi.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
name: napi
on:
push:
branches: [main]
pull_request:
env:
DEBUG: napi:*
APP_NAME: three_em_node
MACOSX_DEPLOYMENT_TARGET: '10.13'
jobs:
build:
name: build / ${{ matrix.target }} / node ${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
node: [14, 16]
include:
- os: macos-latest
target: x86_64-apple-darwin
arch: x64
build: yarn build-release; strip -x *.node
use_sysroot: false
- os: windows-latest
target: x86_64-pc-windows-msvc
arch: x64
build: yarn build-release
use_sysroot: false
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
arch: x64
build: yarn build --release
use_sysroot: true
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.arch }}
cache: 'yarn'
cache-dependency-path: js/napi/yarn.lock
- uses: dtolnay/rust-toolchain@stable
- name: Use Rust Cache
uses: Swatinem/rust-cache@v1
- name: Set up incremental LTO and sysroot build
if: matrix.use_sysroot || startsWith(matrix.os, 'ubuntu')
run: |
# Avoid running man-db triggers, which sometimes takes several minutes
# to complete.
sudo apt-get remove --purge -y man-db
# Install clang-14, lld-14, and debootstrap.
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" |
sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-14.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key |
gpg --dearmor |
sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg
sudo apt-get update
sudo apt-get install --no-install-recommends debootstrap \
clang-14 lld-14
# Create ubuntu-16.04 sysroot environment, which is used to avoid
# depending on a very recent version of glibc.
# `libc6-dev` is required for building any C source files.
# `file` and `make` are needed to build libffi-sys.
# `curl` is needed to build rusty_v8.
sudo debootstrap \
--include=ca-certificates,curl,file,libc6-dev,make \
--no-merged-usr --variant=minbase xenial /sysroot \
http://azure.archive.ubuntu.com/ubuntu
sudo mount --rbind /dev /sysroot/dev
sudo mount --rbind /sys /sysroot/sys
sudo mount --rbind /home /sysroot/home
sudo mount -t proc /proc /sysroot/proc
# Configure the build environment. Both Rust and Clang will produce
# llvm bitcode only, so we can use lld's incremental LTO support.
cat >> $GITHUB_ENV << __0
CARGO_PROFILE_BENCH_INCREMENTAL=false
CARGO_PROFILE_BENCH_LTO=false
CARGO_PROFILE_RELEASE_INCREMENTAL=false
CARGO_PROFILE_RELEASE_LTO=false
RUSTFLAGS<<__1
-C linker-plugin-lto=true
-C linker=clang-14
-C link-arg=-fuse-ld=lld-14
-C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
-C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m
${{ env.RUSTFLAGS }}
__1
RUSTDOCFLAGS<<__1
-C linker-plugin-lto=true
-C linker=clang-14
-C link-arg=-fuse-ld=lld-14
-C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
-C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m
${{ env.RUSTFLAGS }}
__1
CC=clang-14
CFLAGS=-flto=thin --sysroot=/sysroot
__0
- name: Install Node Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: ./js/napi
useLockFile: false
- name: Build
working-directory: ./js/napi
run: ${{ matrix.build }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-${{ matrix.target }}
path: ./js/napi/${{ env.APP_NAME }}.*.node
if-no-files-found: error
test:
name: test / ${{ matrix.target }} / node ${{ matrix.node }}
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [14, 16]
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
cache-dependency-path: js/napi/yarn.lock
- name: Install Node Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: ./js/napi
useLockFile: false
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: bindings-${{ matrix.target }}
path: ./js/napi
- name: List packages
working-directory: ./js/napi
run: ls -R .
- name: Test bindings
working-directory: ./js/napi
run: yarn test
publish:
name: publish
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
cache-dependency-path: js/napi/yarn.lock
- name: Install Node Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: ./js/napi
useLockFile: false
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: ./js/napi/artifacts
- name: Move artifacts
working-directory: ./js/napi
run: yarn artifacts
- name: List packages
working-directory: ./js/napi
run: ls -R ./npm
shell: bash
- name: Publish
working-directory: ./js/napi
run: |
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}