Repository navigation
194 lines (188 loc) · 7.54 KB
/
Copy pathrelease-python.yml
File metadata and controls
194 lines (188 loc) · 7.54 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
name: release-python
# Wheels for parsec-html on PyPI, built when a v* tag is pushed: one per
# CPython version from 3.9 to 3.15, free-threaded 3.14t and 3.15t
# included (PyO3 doesn't support free-threaded 3.13), then an abi3t wheel (stable ABI, any CPython from 3.15,
# free-threaded too) for the versions after. A manual run builds them all
# and publishes nothing, to try a release first.
#
# Publishing is PyPI's trusted publishing, so no token is stored here. It
# stays off until the maintainer has added this workflow as a trusted
# publisher on PyPI, created the `release` environment, and set the
# repository variable PYPI_PUBLISH to true.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
wheels:
strategy:
fail-fast: false
matrix:
platform:
- { runner: ubuntu-latest, target: x86_64, manylinux: auto }
- { runner: ubuntu-24.04-arm, target: aarch64, manylinux: auto }
- { runner: ubuntu-latest, target: x86_64, manylinux: musllinux_1_2 }
- { runner: ubuntu-24.04-arm, target: aarch64, manylinux: musllinux_1_2 }
- { runner: macos-15-intel, target: x86_64 }
- { runner: macos-latest, target: aarch64 }
- { runner: windows-latest, target: x64 }
- { runner: windows-11-arm, target: aarch64, pythons: "3.11 3.12 3.13 3.14 3.15 3.14t 3.15t" }
runs-on: ${{ matrix.platform.runner }}
timeout-minutes: 45
env:
# The versions with a wheel of their own. Windows on ARM has CPython
# from 3.11.
PYTHONS: ${{ matrix.platform.pythons || '3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.14t 3.15t' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Linux builds in manylinux containers, which have every version;
# macOS and Windows build with what's installed here.
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: runner.os != 'Linux' && matrix.platform.runner != 'windows-11-arm'
with:
python-version: |
3.9
3.10
3.11
3.12
3.13
3.14
3.15
3.14t
3.15t
# Windows on ARM has CPython from 3.11.
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: matrix.platform.runner == 'windows-11-arm'
with:
python-version: |
3.11
3.12
3.13
3.14
3.15
3.14t
3.15t
# The manylinux images name each version python3.14, python3.14t and
# so on. On macOS and Windows those names aren't to be trusted (the
# free-threaded python3.14 shadows the other on macOS), so each
# interpreter is found by asking it what it is.
- name: The interpreters
id: pythons
shell: bash
run: |
if [ "$RUNNER_OS" = Linux ]; then
list=$(for v in $PYTHONS; do printf 'python%s ' "$v"; done)
else
# shellcheck disable=SC2086 # one argument a version
list=$(python scripts/find-pythons.py $PYTHONS | tr '\n' ' ')
fi
echo "list=$list" >> "$GITHUB_OUTPUT"
- name: Wheels for each version
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
working-directory: bindings/python
target: ${{ matrix.platform.target }}
manylinux: ${{ matrix.platform.manylinux }}
args: --release --out dist --interpreter ${{ steps.pythons.outputs.list }}
- name: The abi3t wheel
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
working-directory: bindings/python
target: ${{ matrix.platform.target }}
manylinux: ${{ matrix.platform.manylinux }}
args: --release --out dist --features abi3t --interpreter python3.15
# A wheel missing is a version PyPI users get no wheel for, so it
# fails here rather than going out short.
- name: Every wheel is there
shell: bash
working-directory: bindings/python
run: |
ls dist
missing=0
for v in $PYTHONS abi3t; do
case "$v" in
abi3t) tag=cp315-abi3.abi3t ;;
*t) n=${v%t}; n=${n/./}; tag=cp$n-cp${n}t ;;
*) n=${v/./}; tag=cp$n-cp$n ;;
esac
if ! ls dist/*-"$tag"-*.whl > /dev/null 2>&1; then
echo "no $tag wheel" >&2
missing=1
fi
done
count=$(find dist -name '*.whl' | wc -l)
want=$(( $(echo "$PYTHONS" | wc -w) + 1 ))
[ "$count" -eq "$want" ] || { echo "$count wheels, not $want" >&2; missing=1; }
exit "$missing"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}-${{ matrix.platform.manylinux || 'native' }}
path: bindings/python/dist
if-no-files-found: error
sdist:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: The tag is the package's version
if: startsWith(github.ref, 'refs/tags/v')
env:
TAG: ${{ github.ref_name }}
run: |
version=$(sed -n 's/^version = "\(.*\)"$/\1/p' bindings/python/Cargo.toml | head -n 1)
[ "v$version" = "$TAG" ] || { echo "bindings/python/Cargo.toml says $version, the tag $TAG" >&2; exit 1; }
- uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
working-directory: bindings/python
command: sdist
args: --out dist
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: wheels-sdist
path: bindings/python/dist
if-no-files-found: error
publish:
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'parsec-html/parsec' && vars.PYPI_PUBLISH == 'true'
needs: [wheels, sdist]
runs-on: ubuntu-latest
# Most of it is waiting for release.yml.
timeout-minutes: 45
environment:
name: release
url: https://pypi.org/project/parsec-html/
permissions:
# For trusted publishing and the attestations PyPI shows.
id-token: write
# To see release.yml's release.
contents: read
steps:
# release.yml makes the release once the tag's signature checks out
# and the crates have built twice the same; nothing goes to PyPI
# for a tag that fails that.
- name: Wait for release.yml's release
env:
GH_TOKEN: ${{ github.token }}
run: |
for _ in $(seq 60); do
gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1 && exit 0
sleep 30
done
echo "no release for $GITHUB_REF_NAME after 30 minutes: did release.yml fail?" >&2
exit 1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: wheels-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
# So a run that failed part way can be run again.
skip-existing: true