This repository was archived by the owner on Mar 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
337 lines (325 loc) · 11.5 KB
/
release_python.yml
File metadata and controls
337 lines (325 loc) · 11.5 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# Release workflow for the Kaskada Python library.
#
# This flow is triggered by the creation of a new GitHub release.
# Generally, the new release should be marked as a "Pre-Release".
#
# The creation of the release will cause this to determine the version
# and build the Python wheels on multiple platforms, before combining
# them and uploading the new Python library to PyPI.
#
# Ideas for improvement
# ---------------------
# 1. After releasing we should update the `latest` tag. We don't do this
# yet because the old version of the Kaskada Python client downloads
# the latest engine release.
# 2. After releasing, we should update the version in the checked in
# project configurations to be a `-dev` pre-release of the next version.
# 3. We could add a step that uploads the wheels to Test PyPi for verification.
# 4. We could build the wheels on merge to main, allowing the release process
# to retrieve them rather than building them. This would also let us do the
# the bulk of the multi-platform testing regularly, as well as making it
# less likely that we'd need to recreate a release to deal with problems.
# 5. Schedule a weekly, automatic release.
name: Python Release
# Only one job per-ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
release:
types:
- published
defaults:
run:
shell: bash
working-directory: python
permissions:
contents: read
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Determine version (current)
if: github.event_name != 'release'
run: |
pip install tomlkit packaging
VERSION=$(python ../scripts/version.py get pyproject.toml project.version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Determine version (release)
if: github.event_name == 'release'
run: |
echo "GITHUB_REF=${GITHUB_REF}"
VERSION=${GITHUB_REF#refs/tags/v}
pip install tomlkit packaging
echo "VERSION=${VERSION}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set version
id: set-version
run: |
echo "version=$VERSION" >> $GITHUB_OUTPUT
build-wheel-macos:
# Build wheels during release.
if: github.event_name == 'release'
runs-on: macos-latest
needs: [version]
strategy:
matrix:
include:
- target: x86_64
wheel_suffix: macosx_11_0_x86_64
# - target: arm64
# wheel_suffix: macosx_11_0_arm64
- target: universal2
wheel_suffix: macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/setup-python@v4
with:
python-version: |
3.9
3.10
3.11
architecture: x64
cache: poetry
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Version (For Release)
if: github.event_name == 'release'
run: |
pip install tomlkit packaging
python ../scripts/version.py set ${{ needs.version.outputs.version }} \
pyproject.toml:project.version \
pyproject.toml:tool.poetry.version \
Cargo.toml:package.version
- name: Build wheel
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --sdist
working-directory: python
- name: pytest and mypy
if: matrix.target != 'arm64'
run: |
pip install tomlkit packaging
VERSION=$(python ../scripts/version.py normalize ${{ needs.version.outputs.version }})
WHEEL="dist/kaskada-${VERSION}-cp38-abi3-${{ matrix.wheel_suffix }}.whl"
echo "WHEEL:${WHEEL}"
for V in 3.9 3.10 3.11; do
echo "::group::Install for Python $V"
poetry env use $V
source $(poetry env info --path)/bin/activate
poetry install --only=test --only=typecheck
pip install ${WHEEL} --force-reinstall
echo "::endgroup::"
echo "::group::Test Python $V"
poetry run pytest
echo "::endgroup::"
echo "::group::MyPy Python $V"
poetry run mypy -- --install-types --non-interactive pysrc pytests
echo "::endgroup::"
deactivate
done
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ${{ github.workspace }}/python/dist
build-wheel-windows:
if: github.event_name == 'release'
needs: [version]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/setup-python@v4
with:
python-version: 3.11
architecture: x64
cache: poetry
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Version (For Release)
if: github.event_name == 'release'
run: |
pip install tomlkit packaging
python ../scripts/version.py set ${{ needs.version.outputs.version }} \
pyproject.toml:project.version \
pyproject.toml:tool.poetry.version \
Cargo.toml:package.version
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: x64
args: --release --out dist
working-directory: python
- name: pytest and mypy (Windows x64)
shell: bash
run: |
echo "::group::Install for Python 3.11"
source $(poetry env info --path)\\Scripts\\activate
poetry install --only=test --only=typecheck
pip install tomlkit packaging
VERSION=$(python ../scripts/version.py normalize ${{ needs.version.outputs.version }})
WHEEL="dist/kaskada-${VERSION}-cp38-abi3-win_amd64.whl"
echo "WHEEL:${WHEEL}"
pip install ${WHEEL} --force-reinstall
echo "::endgroup::"
echo "::group::Test Python 3.11"
poetry run pytest
echo "::endgroup::"
echo "::group::MyPy Python 3.11"
poetry run mypy -- --install-types --non-interactive pysrc pytests
echo "::endgroup::"
deactivate
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ${{ github.workspace }}/python/dist
build-wheel-linux:
if: github.event_name == 'release'
needs: [version]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/setup-python@v4
with:
python-version: |
3.9
3.10
3.11
cache: poetry
- name: Set Version (For Release)
if: github.event_name == 'release'
run: |
pip install tomlkit packaging
python ../scripts/version.py set ${{ needs.version.outputs.version }} \
pyproject.toml:project.version \
pyproject.toml:tool.poetry.version \
Cargo.toml:package.version
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: 2_28
args: --release --out dist
working-directory: python
before-script-linux: |
set -e
dnf -y install clang protobuf-devel lld
clang --version
protoc --version
- name: pytest and mypy (Linux x86_64)
if: matrix.target == 'x86_64'
run: |
pip install tomlkit packaging
VERSION=$(python ../scripts/version.py normalize ${{ needs.version.outputs.version }})
WHEEL="dist/kaskada-${VERSION}-cp38-abi3-manylinux_2_28_${{ matrix.target }}.whl"
echo "WHEEL:${WHEEL}"
for V in 3.9 3.10 3.11; do
echo "::group::Install for Python $V"
poetry env use $V
poetry env info
source $(poetry env info --path)/bin/activate
poetry install --only=test --only=typecheck
pip install ${WHEEL} --force-reinstall
echo "::endgroup::"
echo "::group::Test Python $V"
poetry run pytest
echo "::endgroup::"
echo "::group::MyPy Python $V"
poetry run mypy -- --install-types --non-interactive pysrc pytests
echo "::endgroup::"
deactivate
done
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ${{ github.workspace }}/python/dist
# Make the source distribution
sdist:
if: github.event_name == 'release'
needs: [version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Version (For Release)
if: github.event_name == 'release'
run: |
pip install tomlkit packaging
python ../scripts/version.py set ${{ needs.version.outputs.version }} \
pyproject.toml:project.version \
pyproject.toml:tool.poetry.version \
Cargo.toml:package.version
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: python
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: ${{ github.workspace }}/python/dist
release:
name: Release
runs-on: ubuntu-latest
environment: pypi
needs: [build-wheel-linux, build-wheel-windows, build-wheel-macos, sdist]
permissions:
# Fetch the OpenID Connect token used to publish to PyPi.
id-token: write
# For deploying release artifacts.
contents: write
# For creating the release announcement.
discussions: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
- name: Publish release
# We don't need the source for the release, so we don't currently check it out.
# However, we set a default working-directory of `python` which is within the source.
# To avoid problems, we explicitly set the working-directory to the root here.
working-directory:
run: |
gh release edit ${{ github.ref_name }} \
--draft=false --latest --discussion-category "Announcements"
env:
GH_TOKEN: ${{ github.token }}