-
-
Notifications
You must be signed in to change notification settings - Fork 6
256 lines (220 loc) · 7.41 KB
/
release.yml
File metadata and controls
256 lines (220 loc) · 7.41 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
name: Build and publish wheels
on:
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
permissions:
contents: read
env:
RUST_VERSION: "1.90.0"
jobs:
build:
name: Build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
target: [ x86_64, aarch64 ]
manylinux: [ auto ]
include:
# not PGO optimized:
- os: windows
target: x86_64
interpreter: pypy3.11
- os: windows
target: i686
python-architecture: x86
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 3.14
- os: windows
target: aarch64
interpreter: 3.11 3.12 3.13 3.14
- os: macos
target: x86_64
interpreter: pypy3.11
- os: macos
target: aarch64
# actions/setup-python@v5 does not support 3.8 and 3.9 on arm64
interpreter: 3.8 3.9 pypy3.11
- os: ubuntu
target: x86_64
interpreter: pypy3.11
- os: ubuntu
target: i686
- os: ubuntu
target: aarch64
- os: ubuntu
target: armv7
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 3.14
- os: ubuntu
target: ppc64le
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 3.14
- os: ubuntu
target: s390x
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 3.14
- os: ubuntu
target: x86_64
manylinux: musllinux_1_1
- os: ubuntu
target: aarch64
manylinux: musllinux_1_1
exclude:
# Windows on arm64 only supports Python 3.11+
- os: windows
target: aarch64
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: ${{ matrix.python-architecture || 'x64' }}
- name: Install rust
id: rust-toolchain
uses: dtolnay/rust-toolchain@master
with:
components: llvm-tools
toolchain: ${{ env.RUST_VERSION }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 3.14 pypy3.11' }}
rust-toolchain: ${{ env.RUST_VERSION }}
docker-options: -e CI
- name: List wheels.
run: ${{ (runner.os == 'Windows' && 'dir') || 'ls -lh' }} dist/
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: pypi_wheels_${{ matrix.os }}_${{ matrix.target }}_${{ matrix.interpreter || 'all' }}_${{ matrix.manylinux }}
path: dist
build-pgo:
name: PGO build on ${{ matrix.os }} / ${{ matrix.interpreter }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ]
interpreter: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
exclude:
# actions/setup-python@v5 does not support 3.8 and 3.9 on arm64
- os: macos-14
interpreter: '3.8'
- os: macos-14
interpreter: '3.9'
runs-on: ${{ matrix.os }}
steps:
- name: Set Git to use LF.
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository.
uses: actions/checkout@v4
- uses: actions/setup-python@v5 # required for macos-13 with Python 3.8-3.10... otherwise UV uses PyPy...
with:
python-version: ${{ matrix.interpreter }}
- name: Install UV.
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.interpreter }}
- name: Install rust.
id: rust-toolchain
uses: dtolnay/rust-toolchain@master
with:
components: llvm-tools
toolchain: ${{ env.RUST_VERSION }}
- name: Set RUST_HOST.
shell: bash
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV"
- name: Build wheel with profile generation.
uses: PyO3/maturin-action@v1
with:
manylinux: auto
args: --release --out pgo-wheel --interpreter ${{ matrix.interpreter }}
rust-toolchain: ${{ env.RUST_VERSION }}
docker-options: -e CI
env:
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/profdata"
- name: Gather PGO data.
run: |
uv sync --group testing
uv pip install libipld --no-index --no-deps --find-links pgo-wheel --force-reinstall
uv run pytest . --benchmark-enable
# we can't use github.workspace here because of Windows with backslashes
rustup run ${{ env.RUST_VERSION }} bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/${{ env.RUST_HOST }}/bin/llvm-profdata >> "$GITHUB_ENV"'
- name: Prepare merged PGO data.
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
- name: Build PGO-optimized wheel.
uses: PyO3/maturin-action@v1
with:
manylinux: auto
args: --release --out dist --interpreter ${{ matrix.interpreter }}
rust-toolchain: ${{ env.RUST_VERSION }}
docker-options: -e CI
env:
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"
- name: List wheels.
run: ${{ (runner.os == 'Windows' && 'dir') || 'ls -lh' }} dist/
- name: Upload wheels.
uses: actions/upload-artifact@v4
with:
name: pypi_pgo_wheels_${{ matrix.os }}_${{ matrix.interpreter }}
path: dist
build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist.
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist.
uses: actions/upload-artifact@v4
with:
name: pypi_sdist
path: dist
check:
needs: [ build, build-pgo, build-sdist ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Get dist artifacts.
uses: actions/download-artifact@v4
with:
pattern: pypi_*
merge-multiple: true
path: dist
- name: List dist files.
run: |
ls -lh dist/
ls -l dist/
echo "`ls dist | wc -l` files"
- name: Check wheels.
run: |
pip install -U twine
twine check --strict dist/*
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ build, build-pgo, build-sdist, check ]
steps:
- uses: actions/download-artifact@v4
with:
pattern: pypi_*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing dist/*