Repository navigation
265 lines (235 loc) · 9.41 KB
/
Copy pathpython-release.yml
File metadata and controls
265 lines (235 loc) · 9.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
257
258
259
260
261
262
263
264
265
name: python-release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
jobs:
validate-version:
if: github.repository == 'nyoki-mtl/rsshogi'
name: Validate Python package versions
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate package versions
shell: bash
run: |
set -euo pipefail
PYPROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/rsshogi-py/pyproject.toml | head -n1)"
AVX2_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/rsshogi-py/pyproject-avx2.toml | head -n1)"
CARGO_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/rsshogi-py/Cargo.toml | head -n1)"
CORE_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/rsshogi/Cargo.toml | head -n1)"
INIT_VERSION="$(sed -n 's/^__version__ = "\(.*\)"/\1/p' crates/rsshogi-py/python/rsshogi/__init__.py | head -n1)"
UV_VERSION="$(awk '$0 == "name = \"rsshogi\"" { getline; if ($1 == "version") { gsub(/\"/, "", $3); print $3; exit } }' crates/rsshogi-py/uv.lock)"
if [ -z "${PYPROJECT_VERSION}" ] || [ -z "${AVX2_VERSION}" ] || [ -z "${CARGO_VERSION}" ] || [ -z "${CORE_VERSION}" ] || [ -z "${INIT_VERSION}" ] || [ -z "${UV_VERSION}" ]; then
echo "Failed to read one or more Python package versions"
exit 1
fi
if [ "${PYPROJECT_VERSION}" != "${AVX2_VERSION}" ] || [ "${PYPROJECT_VERSION}" != "${CARGO_VERSION}" ] || [ "${PYPROJECT_VERSION}" != "${CORE_VERSION}" ] || [ "${PYPROJECT_VERSION}" != "${INIT_VERSION}" ] || [ "${PYPROJECT_VERSION}" != "${UV_VERSION}" ]; then
echo "Package versions differ: pyproject=${PYPROJECT_VERSION}, avx2=${AVX2_VERSION}, cargo=${CARGO_VERSION}, core=${CORE_VERSION}, __version__=${INIT_VERSION}, uv=${UV_VERSION}"
exit 1
fi
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "${TAG_VERSION}" != "${PYPROJECT_VERSION}" ]; then
echo "Tag version (${TAG_VERSION}) does not match Python package version (${PYPROJECT_VERSION})"
exit 1
fi
fi
build-wheels:
if: github.repository == 'nyoki-mtl/rsshogi'
name: Build Wheels (${{ matrix.os }})
needs: validate-version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- windows-latest
- macos-latest
- macos-15-intel
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build wheels (manylinux)
if: runner.os == 'Linux'
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: build
rust-toolchain: 1.95.0
manylinux: "2014"
args: --release --manifest-path crates/rsshogi-py/Cargo.toml --out dist --find-interpreter
- name: Build wheels (native)
if: runner.os != 'Linux'
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: build
rust-toolchain: 1.95.0
args: --release --manifest-path crates/rsshogi-py/Cargo.toml --out dist --find-interpreter
- name: Upload wheel artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-standard-${{ matrix.os }}
path: dist/*.whl
retention-days: 1
build-wheels-avx2:
if: github.repository == 'nyoki-mtl/rsshogi'
name: Build Wheels AVX2 (${{ matrix.os }})
needs: validate-version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-15-intel
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Switch to AVX2 pyproject
shell: bash
run: cp crates/rsshogi-py/pyproject-avx2.toml crates/rsshogi-py/pyproject.toml
- name: Build AVX2 wheels (manylinux)
if: runner.os == 'Linux'
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: build
rust-toolchain: 1.95.0
manylinux: "2014"
args: --release --manifest-path crates/rsshogi-py/Cargo.toml --out dist --find-interpreter
- name: Build AVX2 wheels (native)
if: runner.os != 'Linux'
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: build
rust-toolchain: 1.95.0
args: --release --manifest-path crates/rsshogi-py/Cargo.toml --out dist --find-interpreter
- name: Upload AVX2 wheel artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-avx2-${{ matrix.os }}
path: dist/*.whl
retention-days: 1
build-sdist:
if: github.repository == 'nyoki-mtl/rsshogi'
name: Build Source Distribution
needs: validate-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build sdist
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: sdist
rust-toolchain: 1.95.0
args: --manifest-path crates/rsshogi-py/Cargo.toml --out dist
- name: Check library build from sdist
shell: bash
run: |
set -euo pipefail
mkdir "${RUNNER_TEMP}/sdist-standard"
tar -xzf dist/*.tar.gz -C "${RUNNER_TEMP}/sdist-standard"
roots=("${RUNNER_TEMP}/sdist-standard"/*)
cargo check --manifest-path "${roots[0]}/crates/rsshogi-py/Cargo.toml" --lib --locked
- name: Upload sdist artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdist
path: dist/*.tar.gz
retention-days: 1
build-sdist-avx2:
if: github.repository == 'nyoki-mtl/rsshogi'
name: Build Source Distribution AVX2
needs: validate-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Switch to AVX2 pyproject
shell: bash
run: cp crates/rsshogi-py/pyproject-avx2.toml crates/rsshogi-py/pyproject.toml
- name: Build AVX2 sdist
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: sdist
rust-toolchain: 1.95.0
args: --manifest-path crates/rsshogi-py/Cargo.toml --out dist
- name: Check library build from AVX2 sdist
shell: bash
run: |
set -euo pipefail
mkdir "${RUNNER_TEMP}/sdist-avx2"
tar -xzf dist/*.tar.gz -C "${RUNNER_TEMP}/sdist-avx2"
roots=("${RUNNER_TEMP}/sdist-avx2"/*)
cargo check --manifest-path "${roots[0]}/crates/rsshogi-py/Cargo.toml" --lib --locked
- name: Upload AVX2 sdist artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdist-avx2
path: dist/*.tar.gz
retention-days: 1
publish-standard:
name: Publish standard distribution to PyPI
runs-on: ubuntu-latest
needs:
- build-wheels
- build-wheels-avx2
- build-sdist
- build-sdist-avx2
if: github.repository == 'nyoki-mtl/rsshogi' && startsWith(github.ref, 'refs/tags/v')
environment: pypi
permissions:
id-token: write
steps:
- name: Download standard wheel artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: wheels-standard-*
path: dist
merge-multiple: true
- name: Download sdist artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sdist
path: dist
- name: Publish standard distribution to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1.14.2
with:
packages-dir: dist
skip-existing: true
publish-avx2:
name: Publish AVX2 distribution to PyPI
runs-on: ubuntu-latest
needs:
- build-wheels
- build-wheels-avx2
- build-sdist
- build-sdist-avx2
if: github.repository == 'nyoki-mtl/rsshogi' && startsWith(github.ref, 'refs/tags/v')
environment: pypi-avx2
permissions:
id-token: write
steps:
- name: Download AVX2 wheel artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: wheels-avx2-*
path: dist
merge-multiple: true
- name: Download AVX2 sdist artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sdist-avx2
path: dist
- name: Publish AVX2 distribution to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1.14.2
with:
packages-dir: dist
skip-existing: true