-
Notifications
You must be signed in to change notification settings - Fork 1
320 lines (278 loc) · 10.5 KB
/
build.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
name: Build
on:
workflow_dispatch:
release:
types:
- published
# push:
# branches:
# - main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# cf. https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/artifacts.yml
jobs:
binary_linux:
name: 🐧 Build binaries for Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update && rustup target add aarch64-unknown-linux-gnu
- run: |
sudo apt update && sudo apt install -y g++-aarch64-linux-gnu
echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
- uses: Swatinem/rust-cache@v2
- run: cargo build --release
working-directory: ./cli
- run: cargo build --release --target aarch64-unknown-linux-gnu
working-directory: ./cli
env:
BINDGEN_EXTRA_CLANG_ARGS: --sysroot /usr/aarch64-linux-gnu
- uses: actions/upload-artifact@v3
with:
name: nanopub_x86_64_linux_gnu
path: target/release/nanopub-cli
- uses: actions/upload-artifact@v3
with:
name: nanopub_aarch64_linux_gnu
path: target/aarch64-unknown-linux-gnu/release/nanopub-cli
- if: github.event_name == 'release'
run: |
mv target/release/nanopub-cli nanopub_x86_64_linux_gnu
mv target/aarch64-unknown-linux-gnu/release/nanopub-cli nanopub_aarch64_linux_gnu
- uses: softprops/action-gh-release@v1
if: github.event_name == 'release'
with:
files: |
nanopub_x86_64_linux_gnu
nanopub_aarch64_linux_gnu
# nanopub_${{ github.event.release.tag_name }}_x86_64_linux_gnu
# tag_name: ${{ github.event.release.tag_name }}
binary_mac:
name: 🍎 Build binaries for MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update && rustup target add aarch64-apple-darwin
- run: |
sudo apt update && sudo apt install -y g++-aarch64-linux-gnu
echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
- uses: Swatinem/rust-cache@v2
- run: cargo build --release
working-directory: ./cli
- run: cargo build --release --target aarch64-apple-darwin
working-directory: ./cli
- uses: actions/upload-artifact@v3
with:
name: nanopub_x86_64_apple
path: target/release/nanopub-cli
- uses: actions/upload-artifact@v3
with:
name: nanopub_aarch64_apple
path: target/aarch64-apple-darwin/release/nanopub
- if: github.event_name == 'release'
run: |
mv target/release/nanopub-cli nanopub_x86_64_apple
mv target/aarch64-apple-darwin/release/nanopub-cli nanopub_aarch64_apple
- uses: softprops/action-gh-release@v1
if: github.event_name == 'release'
with:
files: |
nanopub_x86_64_apple
nanopub_aarch64_apple
binary_windows:
name: 🪟 Build binaries for Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo build --release
working-directory: ./cli
- uses: actions/upload-artifact@v3
with:
name: nanopub_x86_64_windows_msvc
path: target/release/nanopub-cli.exe
- if: github.event_name == 'release'
run: |
mv target/release/nanopub-cli.exe nanopub_x86_64_windows_msvc.exe
- uses: softprops/action-gh-release@v1
if: github.event_name == 'release'
with:
files: |
nanopub_x86_64_windows_msvc.exe
wheel_linux:
name: 🐍🐧 Build wheel for Linux
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [ "x86_64", "aarch64" ]
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: docker/setup-qemu-action@v2
with:
platforms: linux/${{ matrix.architecture }}
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/manylinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/manylinux_build_script.sh
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build_script.sh
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
- uses: actions/upload-artifact@v3
with:
name: nanopub_wheel_${{ matrix.architecture }}_linux
path: target/wheels/*.whl
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: target/wheels
if: github.event_name == 'release'
wheel_linux_musl:
name: 🐍🐧 Build wheel for MUSL Linux
runs-on: ubuntu-latest
strategy:
matrix:
architecture:
- "x86_64"
# - "aarch64" # Takes too long (1h30)
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: docker/setup-qemu-action@v2
with:
platforms: linux/${{ matrix.architecture }}
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/musllinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/musllinux_build_script.sh
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/musllinux_1_1_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/musllinux_build_script.sh
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
- uses: actions/upload-artifact@v3
with:
name: nanopub_wheel_${{ matrix.architecture }}_linux_musl
path: target/wheels/*.whl
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: target/wheels
if: github.event_name == 'release'
wheel_mac:
name: 🐍🍎 Build wheel for MacOS
runs-on: macos-latest
env:
DEVELOPER_DIR: '/Applications/Xcode.app/Contents/Developer'
SDKROOT: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk'
MACOSX_DEPLOYMENT_TARGET: '10.14'
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update && rustup target add aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: '**/requirements.dev.txt'
- run: pip install -r python/requirements.dev.txt
- run: maturin build --release -m python/Cargo.toml
- run: pip install --no-index --find-links=target/wheels/ nanopub_sign
- run: rm -r target/wheels
- run: maturin build --release --target universal2-apple-darwin -m python/Cargo.toml
- run: maturin build --release -m python/Cargo.toml
if: github.event_name == 'release'
- run: maturin build --release --target aarch64-apple-darwin -m python/Cargo.toml
if: github.event_name == 'release'
- uses: actions/upload-artifact@v3
with:
name: nanopub_wheel_universal2_mac
path: target/wheels/*.whl
- run: pip install twine && twine upload target/wheels/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
if: github.event_name == 'release'
wheel_windows:
name: 🐍🪟 Build wheel for Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: '**/requirements.dev.txt'
- run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
- run: pip install -r python/requirements.dev.txt
- run: maturin build --release -m python/Cargo.toml
- run: pip install --no-index --find-links=target/wheels/ nanopub_sign
- run: rm -r target/wheels
- run: maturin build --release -m python/Cargo.toml
- run: maturin sdist -m python/Cargo.toml
- uses: actions/upload-artifact@v3
with:
name: nanopub_wheel_x86_64_windows
path: target/wheels/*.whl
- run: pip install twine && twine upload target/wheels/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
if: github.event_name == 'release'
npm_tarball:
name: 🦊 Build npm package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodule: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- name: Install wasm-pack for JS
run: cargo install wasm-pack || true
- name: Setup node for JS
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: npm
cache-dependency-path: "./js/package.json"
- name: Build npm package
run: npm run pack
working-directory: ./js
- name: Upload tarball
uses: actions/upload-artifact@v3
with:
name: nanopub_rs_npm
path: ./js/pkg
- run: npm run release
working-directory: ./js
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: github.event_name == 'release'
publish_crates:
name: 📦️ Publish crates to crates.io
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update
- run: cargo login $CRATES_IO_TOKEN
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- run: cargo publish
working-directory: ./lib