forked from kubeflow/kale
-
Notifications
You must be signed in to change notification settings - Fork 0
285 lines (244 loc) · 8.72 KB
/
release.yml
File metadata and controls
285 lines (244 loc) · 8.72 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
name: Release
on:
workflow_dispatch:
inputs:
target:
description: 'Release target'
type: choice
default: 'dry-run'
options:
- dry-run
- testpypi
- testpypi+pypi
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Extract version
id: version
run: |
VERSION=$(python3 -c "
import re, sys
m = re.search(r'__version__\s*=\s*\"([^\"]+)\"', open('kale/__init__.py').read())
if not m: sys.exit('Could not find __version__')
print(m.group(1))
")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
# Detect prerelease (a=alpha, b=beta, rc=release candidate)
if echo "$VERSION" | grep -qE '(a|b|rc)[0-9]+$'; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
echo "Version: $VERSION"
echo "Tag: v$VERSION"
build:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Install uv
uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "22"
- name: Install dependencies
run: |
SKIP_JUPYTER_BUILDER=1 uv sync --all-extras --frozen
cd labextension && uv run jlpm install
- name: Build labextension
run: |
cd labextension && uv run jlpm build:prod
- name: Check versions match
run: make check-versions
- name: Lint
run: make lint
- name: Test backend
run: make test-backend-unit
- name: Test labextension
run: make test-labextension
- name: Build wheel
run: make build
- name: Check wheel
run: |
pip install twine
twine check dist/*.whl
- name: Upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: wheel
path: |
dist/kubeflow_kale-*.whl
dist/kubeflow_kale-*.tar.gz
if-no-files-found: error
test-wheels:
needs: [prepare, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Download wheel
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: wheel
path: wheels/
- name: Install wheel (lean, no jupyter)
run: |
python -m venv /tmp/test-env
source /tmp/test-env/bin/activate
pip install wheels/kubeflow_kale-*.whl
- name: Smoke test - version
run: |
source /tmp/test-env/bin/activate
python -c "from kale import __version__; print(f'kale version: {__version__}')"
test "$(source /tmp/test-env/bin/activate && python -c 'from kale import __version__; print(__version__)')" = "${{ needs.prepare.outputs.version }}"
- name: Smoke test - CLI
run: |
source /tmp/test-env/bin/activate
kale --help
- name: Install wheel with jupyter extra
run: |
python -m venv /tmp/test-env-jupyter
source /tmp/test-env-jupyter/bin/activate
WHEEL=$(ls wheels/kubeflow_kale-*.whl)
pip install "jupyterlab>=4.0.0,<5" "${WHEEL}[jupyter]"
- name: Smoke test - labextension
run: |
source /tmp/test-env-jupyter/bin/activate
jupyter labextension list 2>&1 | grep -i "jupyterlab-kubeflow-kale"
create-tag:
needs: [prepare, test-wheels]
if: ${{ inputs.target != 'dry-run' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Create and push tag
run: |
TAG="${{ needs.prepare.outputs.tag }}"
# Check if tag already exists
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
else
git tag "$TAG"
git push origin "$TAG"
echo "Created and pushed tag $TAG"
fi
publish-testpypi:
needs: [prepare, create-tag]
if: ${{ inputs.target != 'dry-run' }}
runs-on: ubuntu-latest
environment: release
steps:
- name: Download wheel
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: wheel
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
with:
packages-dir: dist/
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TESTPYPI_API_TOKEN }}
skip-existing: true
publish-pypi:
needs: [prepare, publish-testpypi]
if: ${{ inputs.target == 'testpypi+pypi' }}
runs-on: ubuntu-latest
environment: production
steps:
- name: Download wheel
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: wheel
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_API_TOKEN }}
github-release:
needs: [prepare, publish-testpypi]
if: ${{ inputs.target != 'dry-run' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Download wheel
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: wheel
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: ${{ needs.prepare.outputs.tag }}
prerelease: ${{ needs.prepare.outputs.prerelease == 'true' }}
generate_release_notes: true
files: dist/*
bump-dev-version:
needs: [prepare, publish-testpypi]
if: ${{ inputs.target != 'dry-run' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.ref }}
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "22"
- name: Compute next dev version
id: next
run: |
VERSION="${{ needs.prepare.outputs.version }}"
NEXT=$(python3 -c "
import re
v = '$VERSION'
m = re.match(r'(\d+\.\d+\.\d+)(a|b|rc)(\d+)$', v)
if m:
print(f'{m.group(1)}{m.group(2)}{int(m.group(3))+1}')
else:
parts = v.split('.')
parts[2] = str(int(parts[2]) + 1)
print('.'.join(parts) + 'a1')
")
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "Released $VERSION → next dev version: $NEXT"
- name: Bump version
run: make release VERSION=${{ steps.next.outputs.next }}
- name: Create pull request
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7
with:
commit-message: "Bump dev version to ${{ steps.next.outputs.next }}"
branch: bump-dev-version/${{ steps.next.outputs.next }}
title: "Bump dev version to ${{ steps.next.outputs.next }}"
body: "Automated version bump after releasing v${{ needs.prepare.outputs.version }}."
committer: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
signoff: true