-
Notifications
You must be signed in to change notification settings - Fork 106
382 lines (364 loc) · 13.4 KB
/
cd.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
# This workflow builds the binaries, which are released when a "v*" tag is pushed.
# These also include builds for 32bit platforms, which are thus tested as a side-effect.
# This workflow only runs on a push to master and when pushing a version-tag.
#
# The Linux builds are performed on a "manylinux" container. This container
# is designed such that that the resulting binary has minimal dependencies on system
# libraries, and thus works on as many linuxes as possible. It's a thing from the
# Python world, but generally useful.
#
# Each target (operating system + architecture) is built in grouped jobs by operating system.
#
# Each job should specify at least these env vars:
# * TARGET: used in makefile to do cargo build --target $TARGET
# * ARCHIVE_NAME: used by the makefile to package things up
# * WGPU_NATIVE_VERSION: is backed into the binary at compile time
#
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html for Rust build targets.
name: CD
env:
CACHE_SUFFIX: a
WGPU_ANDROID_NDK_VERSION: r27b # 27.1.12297006
on:
workflow_dispatch:
push:
tags: ["v*"]
branches: [trunk, cd]
jobs:
# -----
ios:
# Config
name: release - ${{ matrix.name }}
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
include:
- name: ios-aarch64
target: aarch64-apple-ios
- name: ios-aarch64-simulator
target: aarch64-apple-ios-sim
- name: ios-x86_64-simulator
target: x86_64-apple-ios
env:
TARGET: ${{ matrix.target }}
ARCHIVE_NAME: wgpu-${{ matrix.name }}
steps:
# Common part (same for each build)
- uses: actions/checkout@v4
with:
submodules: true
- name: Set WGPU_NATIVE_VERSION
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Add ios targets
run: rustup target add ${{ matrix.TARGET }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: build-${{ matrix.TARGET }}-${{ matrix.CACHE_SUFFIX }}
# Build
- name: Build
run: make package
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ env.ARCHIVE_NAME }}
# -----
android:
name: release - ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- name: android-i686
target: i686-linux-android
setup_env: |
set -x
ANDROID_NDK_HOME=$HOME/wgpu-deps/ndk/android-ndk-$WGPU_ANDROID_NDK_VERSION
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CC++" >> $GITHUB_ENV
echo "CLANG_PATH=$CC" >> $GITHUB_ENV
echo "CARGO_TARGET_I686_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV
- name: android-x86_64
target: x86_64-linux-android
setup_env: |
set -x
ANDROID_NDK_HOME=$HOME/wgpu-deps/ndk/android-ndk-$WGPU_ANDROID_NDK_VERSION
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CC++" >> $GITHUB_ENV
echo "CLANG_PATH=$CC" >> $GITHUB_ENV
echo "CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV
- name: android-aarch64
target: aarch64-linux-android
setup_env: |
set -x
ANDROID_NDK_HOME=$HOME/wgpu-deps/ndk/android-ndk-$WGPU_ANDROID_NDK_VERSION
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CC++" >> $GITHUB_ENV
echo "CLANG_PATH=$CC" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV
- name: android-armv7
target: armv7-linux-androideabi
setup_env: |
set -x
ANDROID_NDK_HOME=$HOME/wgpu-deps/ndk/android-ndk-$WGPU_ANDROID_NDK_VERSION
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CC++" >> $GITHUB_ENV
echo "CLANG_PATH=$CC" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$CC" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV
env:
TARGET: ${{ matrix.target }}
ARCHIVE_NAME: wgpu-${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Set WGPU_NATIVE_VERSION
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: build-${{ matrix.TARGET }}-${{ matrix.CACHE_SUFFIX }}
- name: Setup Android NDK
run: |
mkdir -p $HOME/wgpu-deps/ndk
cd $HOME/wgpu-deps/ndk
curl -LO https://dl.google.com/android/repository/android-ndk-$WGPU_ANDROID_NDK_VERSION-linux.zip
unzip android-ndk-$WGPU_ANDROID_NDK_VERSION-linux.zip
rm android-ndk-$WGPU_ANDROID_NDK_VERSION-linux.zip
- name: Setup Environment
run: ${{ matrix.setup_env }}
- name: Build
run: make package
shell: bash
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ env.ARCHIVE_NAME }}
# -----
linux:
# Config
name: release - ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- name: linux-x86_64
target: x86_64-unknown-linux-gnu
image: manylinux_2_28_x86_64
- name: linux-aarch64
target: aarch64-unknown-linux-gnu
image: manylinux_2_28_aarch64
env:
TARGET: ${{ matrix.target }}
ARCHIVE_NAME: wgpu-${{ matrix.name }}
TOOLCHAIN: stable-${{ matrix.target }}
IMAGE: ${{ matrix.image }}
steps:
# Common part (same for nearly each build)
- uses: actions/checkout@v4
with:
submodules: true
- name: Set WGPU_NATIVE_VERSION
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
# prepare qemu for cross-compilation
- name: Set up QEMU
if: matrix.image == 'manylinux_2_28_aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
# Build
- name: Build
run: |
CID=$(docker create -t -w /tmp/wgpu-native -v $PWD:/tmp/src:ro -e TARGET -e ARCHIVE_NAME -e WGPU_NATIVE_VERSION quay.io/pypa/$IMAGE bash -c "\
cp -r /tmp/src/. . && \
rm -rf ./dist && \
export PATH=/root/.cargo/bin:\$PATH && \
export USER=root && \
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none && \
rustup toolchain install --no-self-update $TOOLCHAIN && \
rustup default $TOOLCHAIN && \
dnf install clang-devel zip -y && \
make package")
docker start -ai $CID
mkdir -p dist
docker cp $CID:/tmp/wgpu-native/dist/. dist/.
docker rm $CID
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ env.ARCHIVE_NAME }}
# -----
windows:
# Config
name: release - ${{ matrix.name }}
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
include:
- name: windows-x86_64 - MSVC
target: x86_64-pc-windows-msvc
archive-name: windows-x86_64-msvc
toolchain: stable-msvc
- name: windows-i686 - MSVC
target: i686-pc-windows-msvc
archive-name: windows-i686-msvc
toolchain: stable-msvc
- name: windows-aarch64 - MSVC
target: aarch64-pc-windows-msvc
archive-name: windows-aarch64-msvc
toolchain: stable-msvc
- name: windows-x86_64 - GNU
target: x86_64-pc-windows-gnu
archive-name: windows-x86_64-gnu
toolchain: stable-gnu
env:
TARGET: ${{ matrix.target }}
ARCHIVE_NAME: wgpu-${{ matrix.archive-name }}
steps:
# Common part (same for each build)
- uses: actions/checkout@v4
with:
submodules: true
- name: Set WGPU_NATIVE_VERSION
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ env.TARGET }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: build-${{ env.TARGET }}-${{ env.CACHE_SUFFIX }}
# Build
- name: Build
run: make package
shell: bash
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ env.ARCHIVE_NAME }}
# -----
macos:
# Config
name: release - ${{ matrix.name }}
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
include:
- name: macos-x86_64
target: x86_64-apple-darwin
archive-name: macos-x86_64
- name: macos-aarch64
target: aarch64-apple-darwin
archive-name: macos-aarch64
env:
TARGET: ${{ matrix.target }}
ARCHIVE_NAME: wgpu-${{ matrix.archive-name }}
MACOSX_DEPLOYMENT_TARGET: "10.13"
RUSTFLAGS: "-C link-args=-Wl,-install_name,@rpath/libwgpu_native.dylib"
steps:
# Common part (same for each build)
- uses: actions/checkout@v4
with:
submodules: true
- name: Set WGPU_NATIVE_VERSION
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ env.TARGET }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: build-${{ env.TARGET }}-${{ env.CACHE_SUFFIX }}
# Build
- name: Build
run: make package
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ env.ARCHIVE_NAME }}
# Create a Github release and upload the binary libs that we just built.
# There should be a release and debug build for each platform, plus a file containing the commit sha.
publish:
name: Publish Github release
needs:
- ios
- android
- linux
- windows
- macos
runs-on: ubuntu-latest
if: success() && contains(github.ref, 'tags/v')
steps:
- uses: actions/checkout@v4
- name: set version (which gets used as release name)
run: |
echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Download assets
uses: actions/download-artifact@v4
with:
path: dist
- name: Create commit-sha file
env:
GITHUB_SHA: ${{ github.sha }}
run: |
echo $GITHUB_SHA > dist/commit-sha
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.WGPU_NATIVE_VERSION }}
name: ${{ env.WGPU_NATIVE_VERSION }}
files: |
dist/**/*.zip
dist/commit-sha
body: |
Autogenerated binary modules.
The Linux builds are built on AlmaLinux 8 [manylinux_2_28](https://github.com/pypa/manylinux#manylinux).
The MacOS builds target MacOS 10.13 High Sierra and up.
The Windows builds are built using MSVC on all architectures and GNU on x64.
draft: false
prerelease: false