forked from webviewjs/webview
-
Notifications
You must be signed in to change notification settings - Fork 0
373 lines (332 loc) · 12.5 KB
/
CI.yml
File metadata and controls
373 lines (332 loc) · 12.5 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
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
name: CI
env:
DEBUG: napi:*
APP_NAME: webview
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_INCREMENTAL: '1'
CARGO_TERM_COLOR: always
permissions:
contents: write
id-token: write
on:
push:
branches:
- main
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.settings.os }} - ${{ matrix.settings.target }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
settings:
# macOS
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
build_script: |
export PKG_CONFIG_ALLOW_CROSS=1
bun run build --target aarch64-apple-darwin
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: i686-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
# Linux x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
sys_deps: pkg-config libwebkit2gtk-4.1-dev libsoup-3.0-dev libglib2.0-dev libcairo2-dev libpango1.0-dev libatk1.0-dev libgdk-pixbuf2.0-dev libgtk-3-dev
# Linux ARM64
- os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
cross_arch: arm64
# Added X11, Wayland, and XKB dependencies required by tao/wry
cross_sys_deps: >-
libwebkit2gtk-4.1-dev:arm64
libsoup-3.0-dev:arm64
libgtk-3-dev:arm64
libx11-dev:arm64
libxkbcommon-dev:arm64
libwayland-dev:arm64
libxcb-shape0-dev:arm64
libxcb-xfixes0-dev:arm64
libglib2.0-dev:arm64
libcairo2-dev:arm64
libpango1.0-dev:arm64
libatk1.0-dev:arm64
libgdk-pixbuf2.0-dev:arm64
cross_gcc: gcc-aarch64-linux-gnu
cross_gpp: g++-aarch64-linux-gnu
cross_triplet: aarch64-linux-gnu
build_script: |
set -e
rustup target add aarch64-unknown-linux-gnu
export PKG_CONFIG_ALLOW_CROSS=1
# In Ubuntu Multiarch, the sysroot is actually /
export PKG_CONFIG_SYSROOT_DIR=/
# Only use the target's pkgconfig directory to prevent host library leakage
export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++
export AR=aarch64-linux-gnu-ar
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
bun run build --target aarch64-unknown-linux-gnu
# Linux ARMv7
- os: ubuntu-22.04
target: armv7-unknown-linux-gnueabihf
cross_arch: armhf
# Added X11, Wayland, and XKB dependencies required by tao/wry
cross_sys_deps: >-
libwebkit2gtk-4.1-dev:armhf
libsoup-3.0-dev:armhf
libgtk-3-dev:armhf
libx11-dev:armhf
libxkbcommon-dev:armhf
libwayland-dev:armhf
libxcb-shape0-dev:armhf
libxcb-xfixes0-dev:armhf
libglib2.0-dev:armhf
libcairo2-dev:armhf
libpango1.0-dev:armhf
libatk1.0-dev:armhf
libgdk-pixbuf2.0-dev:armhf
cross_gcc: gcc-arm-linux-gnueabihf
cross_gpp: g++-arm-linux-gnueabihf
cross_triplet: arm-linux-gnueabihf
build_script: |
set -e
rustup target add armv7-unknown-linux-gnueabihf
export PKG_CONFIG_ALLOW_CROSS=1
# In Ubuntu Multiarch, sysroot is /
export PKG_CONFIG_SYSROOT_DIR=/
# Only use target's pkgconfig to prevent host library leakage
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export AR=arm-linux-gnueabihf-ar
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
bun run build --target armv7-unknown-linux-gnueabihf
# Android
- os: ubuntu-latest
target: aarch64-linux-android
- os: ubuntu-latest
target: armv7-linux-androideabi
runs-on: ${{ matrix.settings.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target || matrix.settings.rust_target }}
- name: Setup Zig for cross-compilation
if: matrix.settings.use_zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ matrix.settings.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.settings.target }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: target/
# Added ${{ matrix.settings.os }} to the key
key: ${{ matrix.settings.os }}-${{ matrix.settings.target }}-cargo-build-${{ github.sha }}
restore-keys: |
${{ matrix.settings.os }}-${{ matrix.settings.target }}-cargo-build-
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y pkg-config
- name: Install system dependencies (Linux x86_64)
if: runner.os == 'Linux' && matrix.settings.sys_deps
run: |
sudo apt-get install -y ${{ matrix.settings.sys_deps }}
- name: Install cross-compilation dependencies (Linux ARM)
if: runner.os == 'Linux' && matrix.settings.cross_arch
run: |
sudo dpkg --add-architecture ${{ matrix.settings.cross_arch }}
# 1. Fix existing sources to be amd64-only
# This handles traditional .list files (Jammy 22.04)
sudo find /etc/apt/sources.list /etc/apt/sources.list.d/ -name "*.list" -type f -exec \
sudo sed -i -E 's/^(deb(-src)? )([^[])/\1[arch=amd64] \3/' {} +
# This handles the new DEB822 .sources files (Noble 24.04+)
# It adds "Architectures: amd64" to blocks that don't have it
sudo find /etc/apt/sources.list.d/ /etc/apt/ -name "*.sources" -type f -exec \
sudo sh -c 'grep -q "Architectures:" "$1" || sed -i "/^Types: deb/a Architectures: amd64" "$1"' _ {} \;
# 2. Add the Ports repository for the cross-architecture
CODENAME=$(lsb_release -sc)
echo "deb [arch=${{ matrix.settings.cross_arch }}] http://ports.ubuntu.com/ubuntu-ports $CODENAME main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ports.list
echo "deb [arch=${{ matrix.settings.cross_arch }}] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports.list
echo "deb [arch=${{ matrix.settings.cross_arch }}] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports.list
# 3. Update and install
sudo apt-get update
sudo apt-get install -y \
${{ matrix.settings.cross_gcc }} \
${{ matrix.settings.cross_gpp }} \
${{ matrix.settings.cross_sys_deps }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build
run: ${{ matrix.settings.build_script || format('bun run build --target {0}', matrix.settings.target) }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
retention-days: 7
# build-freebsd:
# runs-on: ubuntu-latest
# name: Build FreeBSD
# timeout-minutes: 90
# steps:
# - uses: actions/checkout@v4
# - name: Build
# id: build
# uses: cross-platform-actions/action@v0.25.0
# env:
# DEBUG: napi:*
# RUSTUP_IO_THREADS: 1
# with:
# operating_system: freebsd
# version: '14.0'
# memory: 8G
# cpu_count: 3
# environment_variables: 'DEBUG RUSTUP_IO_THREADS'
# shell: bash
# run: |
# sudo pkg install -y -f curl node libnghttp2 npm pkg-config
# sudo npm install -g bun --ignore-scripts
# curl https://sh.rustup.rs -sSf --output rustup.sh
# sh rustup.sh -y --profile minimal --default-toolchain beta
# source "$HOME/.cargo/env"
# echo "~~~~ rustc --version ~~~~"
# rustc --version
# echo "~~~~ node -v ~~~~"
# node -v
# echo "~~~~ bun --version ~~~~"
# bun --version
# pwd
# ls -lah
# whoami
# env
# freebsd-version
# bun install
# bun run build
# rm -rf node_modules
# rm -rf target
# rm -rf .bun/cache
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: bindings-freebsd
# path: ${{ env.APP_NAME }}.*.node
# if-no-files-found: error
# retention-days: 7
publish:
name: Publish to npm
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- build
# - build-freebsd
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
run: bun run artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Extract version from commit message
id: version
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
if echo "$COMMIT_MSG" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then
echo "is_release=true" >> $GITHUB_OUTPUT
echo "tag=latest" >> $GITHUB_OUTPUT
elif echo "$COMMIT_MSG" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]"; then
echo "is_release=true" >> $GITHUB_OUTPUT
echo "tag=next" >> $GITHUB_OUTPUT
else
echo "is_release=false" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
if: steps.version.outputs.is_release == 'true'
run: |
npm config set provenance true
npm publish --access public --tag ${{ steps.version.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Skip publish (not a release)
if: steps.version.outputs.is_release == 'false'
run: |
echo "Not a release commit, skipping publish"