-
Notifications
You must be signed in to change notification settings - Fork 1
228 lines (212 loc) · 8.07 KB
/
release.yml
File metadata and controls
228 lines (212 loc) · 8.07 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
name: Release
on:
# Build dev package after CI passes on main (no duplicate test runs)
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [main]
release:
types: [published]
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
# Python versions to build wheels for (must match pyproject.toml requires-python
# and be supported by the PyO3 version in Cargo.toml)
PYTHON_TARGETS: "-i 3.10 -i 3.11 -i 3.12 -i 3.13 -i 3.14"
jobs:
linux:
# Skip if triggered by workflow_run and CI failed
if: >-
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-24.04-arm
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist ${{ env.PYTHON_TARGETS }}
manylinux: auto
rustup-components: llvm-tools
# PGO: Profile-guided optimization. Both targets build natively
# on their respective runners, so PGO works for all Linux wheels.
before-script-linux: |
echo "::group::PGO: Instrumented build + profiling"
# Find best available Python (prefer 3.13, fallback to newest 3.x)
PYDIR=$(find /opt/python -maxdepth 1 -name 'cp313-cp313' -type d 2>/dev/null | head -1)
if [ -z "$PYDIR" ]; then
PYDIR=$(find /opt/python -maxdepth 1 -name 'cp3*' -type d 2>/dev/null | sort -V | tail -1)
fi
if [ -z "$PYDIR" ] || [ ! -x "$PYDIR/bin/python" ]; then
echo "PGO: No suitable Python found in container, skipping PGO"
echo "::endgroup::"
else
PYTHON="$PYDIR/bin/python"
echo "PGO: Using $PYTHON"
# 1. Install ZODB+BTrees for FileStorage benchmarks
$PYTHON -m pip install --quiet ZODB BTrees
# 2. Instrumented build
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" maturin develop --release -i $PYTHON
# 3. Generate profile data with real + synthetic workloads
gunzip -k benchmarks/bench_data/Data.fs.gz || true
$PYTHON benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
$PYTHON benchmarks/bench.py synthetic --iterations 2000
# 4. Merge profiles and set RUSTFLAGS for the final build
LLVM_PROFDATA=$(find /root/.rustup -name llvm-profdata 2>/dev/null | head -1 || true)
if [ -n "$LLVM_PROFDATA" ] && ls /tmp/pgo-data/*.profraw 1>/dev/null 2>&1; then
$LLVM_PROFDATA merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data/*.profraw
export RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata"
echo "PGO: Building with merged profile data"
else
echo "PGO: No profile data found, building without PGO"
fi
echo "::endgroup::"
fi
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist
macos:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- runner: macos-15-intel
target: x86_64
- runner: macos-latest
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: PGO profiling
run: |
set -e
rustup component add llvm-tools
python -m venv .pgo-venv
source .pgo-venv/bin/activate
pip install maturin ZODB BTrees
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" maturin develop --release
gunzip -k benchmarks/bench_data/Data.fs.gz
python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
python benchmarks/bench.py synthetic --iterations 2000
LLVM_PROFDATA=$(find "$(rustc --print sysroot)" -name llvm-profdata | head -1)
if [ -n "$LLVM_PROFDATA" ] && ls /tmp/pgo-data/*.profraw 1>/dev/null 2>&1; then
"$LLVM_PROFDATA" merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data/*.profraw
echo "RUSTFLAGS=-Cprofile-use=/tmp/pgo-data/merged.profdata" >> "$GITHUB_ENV"
echo "PGO: Building with merged profile data"
else
echo "PGO: No profile data found, building without PGO"
fi
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist ${{ env.PYTHON_TARGETS }}
- uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: dist
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
architecture: x64
- name: PGO profiling
shell: bash
run: |
set -e
rustup component add llvm-tools
python -m venv .pgo-venv
source .pgo-venv/Scripts/activate
pip install maturin ZODB BTrees
PGO_DIR="$(cygpath -m "$(pwd)")/pgo-data"
mkdir -p "$PGO_DIR"
RUSTFLAGS="-Cprofile-generate=$PGO_DIR" maturin develop --release
gunzip -k benchmarks/bench_data/Data.fs.gz
python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
python benchmarks/bench.py synthetic --iterations 2000
LLVM_PROFDATA=$(find "$(rustc --print sysroot)" \( -name llvm-profdata -o -name llvm-profdata.exe \) | head -1)
if [ -n "$LLVM_PROFDATA" ] && ls "$PGO_DIR"/*.profraw 1>/dev/null 2>&1; then
"$LLVM_PROFDATA" merge -o "$PGO_DIR/merged.profdata" "$PGO_DIR"/*.profraw
echo "RUSTFLAGS=-Cprofile-use=$PGO_DIR/merged.profdata" >> "$GITHUB_ENV"
echo "PGO: Building with merged profile data"
else
echo "PGO: No profile data found, building without PGO"
fi
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x64
args: --release --out dist ${{ env.PYTHON_TARGETS }}
- uses: actions/upload-artifact@v4
with:
name: wheels-windows-x64
path: dist
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
# Upload to Test PyPI on every push to main
release-test-pypi:
name: Publish to test.pypi.org
if: github.event_name == 'workflow_run' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
needs: [linux, macos, windows, sdist]
runs-on: ubuntu-latest
environment: release-test-pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
# Upload to real PyPI on GitHub Release
release-pypi:
name: Publish to pypi.org
if: github.event.action == 'published'
needs: [linux, macos, windows, sdist]
runs-on: ubuntu-latest
environment: release-pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1