-
Notifications
You must be signed in to change notification settings - Fork 1
276 lines (240 loc) · 8.73 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
name: Build
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
# branches:
# - main
# release:
# types:
# - published
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# cf. https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/artifacts.yml
jobs:
# Build binary for more targets?
# '--target', 'i686-pc-windows-msvc',
# '--target', 'armv7-linux-androideabi',
# '--target', 'thumbv7neon-linux-androideabi',
# '--target', 'aarch64-linux-android',
# '--target', 'i686-linux-android',
# '--target', 'x86_64-linux-android',
build_binaries:
name: 📦️ Binaries for ${{ matrix.os }} (${{ matrix.target }})
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest
strategy:
fail-fast: false
matrix:
include:
- os: linux
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos
target: x86_64-apple-darwin
- os: macos
target: aarch64-apple-darwin
- os: windows
target: x86_64-pc-windows-msvc
- os: windows
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Add cross-compilation target
run: rustup update && rustup target add ${{ matrix.target }}
- name: Install aarch64 linux dependencies
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt update && sudo apt install -y g++-aarch64-linux-gnu
- name: Add aarch64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'aarch64-apple-darwin'
run: echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
# This can't be directly added to cargo config.toml because it makes the wheel build fails
- uses: Swatinem/rust-cache@v2
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
working-directory: ./cli
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nanopub_${{ matrix.target }}
path: target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'windows' && '.exe' || '' }}
- if: startsWith(github.ref, 'refs/tags/')
name: Prepare for release
run: |
mv target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'windows' && '.exe' || '' }} nanopub_${{ matrix.target }}${{ matrix.os == 'windows' && '.exe' || '' }}
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
nanopub_${{ matrix.target }}${{ matrix.os == 'windows' && '.exe' || '' }}
# Inspired by https://github.com/pydantic/pydantic-core/blob/main/.github/workflows/ci.yml
build_wheels:
name: 🐍 Wheels for ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.interpreter || 'all' }}${{ matrix.os == 'linux' && format(' - {0}', matrix.manylinux == 'auto' && 'manylinux' || matrix.manylinux) || '' }})
strategy:
fail-fast: false
matrix:
os: [linux, macos, windows]
target: [x86_64, aarch64]
manylinux: [auto]
include:
# Using pypy when possible for performance
# manylinux for various platforms, plus x86_64 pypy
- os: linux
manylinux: auto
target: i686
- os: linux
manylinux: auto
target: aarch64 # -bit ARM
- os: linux
manylinux: auto
target: armv7 # 32-bit ARM
interpreter: 3.8 3.9 3.10 3.11 3.12
- os: linux
manylinux: auto
target: ppc64le
interpreter: 3.8 3.9 3.10 3.11 3.12
- os: linux
manylinux: auto
target: s390x
interpreter: 3.8 3.9 3.10 3.11 3.12
- os: linux
manylinux: auto
target: x86_64
# musllinux
- os: linux
manylinux: musllinux_1_1
target: x86_64
- os: linux
manylinux: musllinux_1_1
target: aarch64
# MacOS
- os: macos
target: x86_64
- os: macos
target: aarch64
# Windows
# x86_64 pypy builds are not PGO optimized, i686 not supported by pypy, aarch64 only 3.11 and up, also not PGO optimized
- os: windows
target: x86_64
interpreter: 3.8 3.9 3.10 3.11 3.12
# pypy3.9 pypy3.10 failing due to ring
- os: windows
target: i686
python-architecture: x86
interpreter: 3.8 3.9 3.10 3.11 3.12
- os: windows
target: aarch64
interpreter: 3.11 3.12
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
if: matrix.os == 'linux' && matrix.target == 'aarch64'
with:
platforms: linux/${{ matrix.target }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: ${{ matrix.python-architecture || 'x64' }}
- run: pip install -U twine 'ruff==0.1.3' typing_extensions
# generate self-schema now, so we don't have to do so inside docker in maturin build
# - run: python generate_self_schema.py
- name: Build wheels
uses: PyO3/maturin-action@v1
env:
CFLAGS_aarch64_unknown_linux_gnu: -D__ARM_ARCH=8
# NOTE: ring linux aarch64 error: https://github.com/briansmith/ring/issues/1728
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' }}
rust-toolchain: stable
docker-options: -e CI
working-directory: python
- run: ${{ (matrix.os == 'windows' && 'dir') || 'ls -lh' }} python/dist/
- run: twine check --strict python/dist/*
- uses: actions/upload-artifact@v4
with:
name: nanopub_wheel_${{ matrix.os }}_${{ matrix.target }}_${{ matrix.interpreter || 'all' }}_${{ matrix.manylinux }}
path: python/dist
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
run: twine upload python/dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
# - name: Publish to PyPI
# uses: PyO3/maturin-action@v1
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
# with:
# command: upload
# args: --non-interactive --skip-existing *
npm_tarball:
name: 🦊 Build npm package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- name: Install wasm-pack for JS
run: cargo install wasm-pack || true
- name: Setup NodeJS
uses: actions/setup-node@v4
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@v4
with:
name: nanopub_sign_npm
path: ./js/pkg
- run: npm run release
working-directory: ./js
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
publish_crates:
name: 🦀 Publish nanopub crate to crates.io
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update
- run: cargo login $CRATES_IO_TOKEN
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- run: cargo publish
working-directory: ./lib
generate-changelog:
name: 🏔️ Generate changelog for GitHub release
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGES.md
if: startsWith(github.ref, 'refs/tags/')