-
Notifications
You must be signed in to change notification settings - Fork 107
267 lines (258 loc) · 8.33 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
# 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 (os + architecture) is build in a seperate job. This is kinda verbose,
# resulting in some duplication, but at least its easy to read and maintain.
# Don't forget to add new jobs to the needs of the publish job.
#
# 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
on:
workflow_dispatch:
push:
tags: ["v*"]
branches: [trunk, cd]
jobs:
# -----
linux-x86_64:
# Config
name: release - linux-x86_64
runs-on: ubuntu-latest
env:
TARGET: x86_64-unknown-linux-gnu
ARCHIVE_NAME: wgpu-linux-x86_64
TOOLCHAIN: stable-x86_64-unknown-linux-gnu
IMAGE: manylinux_2_28_x86_64
steps:
# Common part (same for nearly each build)
- uses: actions/checkout@v3
with:
submodules: true
- name: Set WGPU_NATIVE_VERSION
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
# 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@v3
with:
path: dist
name: dist
# -----
windows-x86_64:
# Config
name: release - windows-x86_64
runs-on: windows-latest
env:
TARGET: x86_64-pc-windows-msvc
ARCHIVE_NAME: wgpu-windows-x86_64
steps:
# Common part (same for each build)
- uses: actions/checkout@v3
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-msvc
targets: ${{ env.TARGET }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: build-${{ env.TARGET }}-${{ env.CACHE_SUFFIX }}
# Build
- name: Install llvm
run: |
set -x
choco install -y llvm
echo "LIBCLANG_PATH=C:\Program Files\LLVM\lib" >> $GITHUB_ENV
shell: bash
- name: Build
run: make package
shell: bash
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v3
with:
path: dist
name: dist
# -----
windows-i686:
# Config
name: release - windows-i686
runs-on: windows-latest
env:
TARGET: i686-pc-windows-msvc
ARCHIVE_NAME: wgpu-windows-i686
steps:
# Common part (same for each build)
- uses: actions/checkout@v3
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-i686-pc-windows-msvc
targets: ${{ env.TARGET }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: build-${{ env.TARGET }}-${{ env.CACHE_SUFFIX }}
# Build
- name: Install llvm
run: |
set -x
choco install -y --x86 --force llvm
echo "LIBCLANG_PATH=C:\Program Files (x86)\LLVM\lib" >> $GITHUB_ENV
shell: bash
- name: Build
run: make package
shell: bash
# Upload (same for each build)
- name: Upload
uses: actions/upload-artifact@v3
with:
path: dist
name: dist
# -----
macos-x86_64:
# Config
name: release - macos-x86_64
runs-on: macos-latest
env:
TARGET: x86_64-apple-darwin
ARCHIVE_NAME: wgpu-macos-x86_64
MACOSX_DEPLOYMENT_TARGET: "10.13"
steps:
# Common part (same for each build)
- uses: actions/checkout@v3
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@v3
with:
path: dist
name: dist
# -----
macos-arm64:
# Config
name: release - macos-arm64
runs-on: macos-latest
env:
TARGET: aarch64-apple-darwin
ARCHIVE_NAME: wgpu-macos-arm64
MACOSX_DEPLOYMENT_TARGET: "11.0"
steps:
# Common part (same for each build)
- uses: actions/checkout@v3
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@v3
with:
path: dist
name: dist
# Create a Github release and upload the binary libs that we just built.
# There should be a release and debug build for each platform (win32, win64, MacOS64, Linux64),
# plus a file containing the commit sha.
publish:
name: Publish Github release
needs:
[linux-x86_64, windows-x86_64, windows-i686, macos-x86_64, macos-arm64]
runs-on: ubuntu-latest
if: success() && contains(github.ref, 'tags/v')
steps:
- uses: actions/checkout@v3
- 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@v3
with:
name: dist
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@v1
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.
draft: false
prerelease: false