-
Notifications
You must be signed in to change notification settings - Fork 3
274 lines (246 loc) · 9.1 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
name: Build rsapi
env:
DEBUG: 'napi:*'
MACOSX_DEPLOYMENT_TARGET: '10.13'
NODE_OPTIONS: '--max-old-space-size=3072'
CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST: true
CARGO_TARGET_APPLIES_TO_HOST: false
on:
push:
branches:
- master
# tags-ignore:
# - '**'
# paths:
# - 'packages/rsapi'
# - 'sync'
pull_request:
# paths:
# - 'packages/rsapi'
# - 'sync'
jobs:
build-freebsd:
runs-on: macos-12
if: "startsWith(github.event.head_commit.message, 'chore(release): publish')"
name: Build FreeBSD
steps:
- uses: actions/checkout@v3
- name: Build
id: build
uses: cross-platform-actions/[email protected]
env:
DEBUG: 'napi:*'
RUSTUP_HOME: /home/runner/rustup
CARGO_HOME: /home/runner/cargo
RUSTUP_IO_THREADS: 1
with:
operating_system: freebsd
version: '13.2'
memory: 13G
cpu_count: 3
hypervisor: qemu
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
shell: bash
run: |
env | sort
sudo pkg install -y -f curl node libnghttp2 npm
sudo npm install -g yarn --ignore-scripts
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --default-toolchain nightly-2023-12-31
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 --immutable --mode=skip-build
yarn build
strip -x packages/*/*.node
rm -rf node_modules
rm -rf target
rm -rf .yarn/cache
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-freebsd-amd64
path: packages/*/*.node
if-no-files-found: error
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
architecture: x64
target: 'x86_64-apple-darwin'
build: |
yarn build --target x86_64-apple-darwin
strip -x packages/*/*.node
- host: windows-latest
architecture: x64
build: yarn build
target: 'x86_64-pc-windows-msvc'
# Blocked by https://github.com/briansmith/ring/pull/1554
#- host: windows-latest
# architecture: x64
# build: |
# yarn lerna exec "yarn build --target aarch64-pc-windows-msvc" --concurrency 1 --stream --no-prefix
# target: 'aarch64-pc-windows-msvc'
- host: ubuntu-latest
architecture: x64
target: 'x86_64-unknown-linux-gnu'
build: >-
set -e &&
cargo install cargo-zigbuild &&
cargo zigbuild -p rsapi --target x86_64-unknown-linux-gnu.2.17 --release &&
cp -v target/x86_64-unknown-linux-gnu/release/librsapi.so ./packages/rsapi/rsapi.linux-x64-gnu.node &&
strip -x packages/*/*.node
- host: macos-latest
architecture: x64
target: 'aarch64-apple-darwin'
build: |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
export CC=$(xcrun -f clang);
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
yarn build --target aarch64-apple-darwin
strip -x packages/*/*.node
- host: ubuntu-20.04
architecture: x64
target: 'aarch64-unknown-linux-gnu'
setup: |
sudo apt-get update
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
build: |
rustup toolchain install $(cat ./rust-toolchain)
rustup target add aarch64-unknown-linux-gnu
yarn lerna exec "yarn build --target aarch64-unknown-linux-gnu" --concurrency 1 --stream --no-prefix
aarch64-linux-gnu-strip packages/*/*.node
name: stable - ${{ matrix.settings.target }} - node@18
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }}
with:
node-version: 18
check-latest: true
cache: yarn
architecture: ${{ matrix.settings.architecture }}
- name: Install
uses: actions-rs/toolchain@v1
if: ${{ !matrix.settings.docker }}
with:
toolchain: nightly-2023-12-31
profile: minimal
override: true
target: ${{ matrix.settings.target }}
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
if: ${{ !matrix.settings.docker }}
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ matrix.settings.target }}-node@18-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ matrix.settings.target }}-node@18-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v2
with:
path: node_modules
key: npm-cache-${{ matrix.settings.target }}-node@18-${{ hashFiles('yarn.lock') }}
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
run: ${{ matrix.settings.build }}
- name: 'Or Build without docker'
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: packages/*/*.node
if-no-files-found: error
publish:
name: Publish
if: "startsWith(github.event.head_commit.message, 'chore(release): publish')"
runs-on: ubuntu-latest
needs:
- build
- build-freebsd
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: yarn
- name: Cache NPM dependencies
uses: actions/cache@v2
with:
path: node_modules
key: npm-cache-ubuntu-latest-publish-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: List artifacts
run: ls -R artifacts
shell: bash
# BUGGY
#- name: Move artifacts
# run: yarn artifacts
- name: Move artifacts manually
run: |
mv artifacts/bindings-x86_64-unknown-linux-gnu/rsapi/rsapi.linux-x64-gnu.node packages/rsapi/npm/linux-x64-gnu/
mv artifacts/bindings-x86_64-pc-windows-msvc/rsapi/rsapi.win32-x64-msvc.node packages/rsapi/npm/win32-x64-msvc/
mv artifacts/bindings-x86_64-apple-darwin/rsapi/rsapi.darwin-x64.node packages/rsapi/npm/darwin-x64/
mv artifacts/bindings-aarch64-apple-darwin/rsapi/rsapi.darwin-arm64.node packages/rsapi/npm/darwin-arm64/
mv artifacts/bindings-aarch64-unknown-linux-gnu/rsapi/rsapi.linux-arm64-gnu.node packages/rsapi/npm/linux-arm64-gnu/
mv artifacts/bindings-freebsd-amd64/rsapi/rsapi.freebsd-x64.node packages/rsapi/npm/freebsd-x64/
- name: List packages
run: ls -R packages
shell: bash
- name: Lerna publish
if: "startsWith(github.event.head_commit.message, 'chore(release): publish')"
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
# yarn workspaces foreach -A -j 1 run version --no-gh-release
yarn workspaces foreach -A -j 1 run prepublishOnly --no-gh-release
# yarn lerna publish from-package --yes
# ./scripts/publish.sh
cd packages/rsapi && npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}