-
Notifications
You must be signed in to change notification settings - Fork 0
296 lines (238 loc) · 8.23 KB
/
cd.yml
File metadata and controls
296 lines (238 loc) · 8.23 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
name: CD
on:
# Only trigger when release is published
release:
types:
- published
# Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "deployment"
cancel-in-progress: true
permissions:
contents: write # <-- to allow assets to be uploaded to the release
id-token: write # <-- to allow access to the tokens
pages: write # <-- to allow publishing to GitHub Pages
env:
VERSION: ${{ github.event.release.tag_name }}
PACKAGE_NAME: toolbox-python
UV_LINK_MODE: copy
UV_NO_SYNC: true
UV_INDEX_STRATEGY: unsafe-best-match
GITHUB_ACTOR: ${{ github.actor }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
REPOSITORY_NAME: data-science-extensions/toolbox-python
GIT_BRANCH: ${{ github.event.release.target_commitish }}
PYTHON_VERSION: '3.14'
PYTHONIOENCODING: utf-8
jobs:
test:
name: Run Tests
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v5
with:
ref: ${{ env.GIT_BRANCH }}
- name: Set up UV
uses: astral-sh/setup-uv@v6
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
id: install-dependencies
run: uv sync --no-cache --all-groups --upgrade --reinstall-package=${{ env.PACKAGE_NAME }}
- name: Set up Git
id: setup-git
env:
GITHUB_ACTOR: ${{ github.actor }}
run: |
uv run ./src/utils/scripts.py add_git_credentials
uv run ./src/utils/scripts.py git_switch_to_branch ${{ env.GIT_BRANCH }}
uv run ./src/utils/scripts.py git_refresh_current_branch
- name: Run checks
id: run-checks
run: uv run ./src/utils/scripts.py check
- name: Add coverage report
id: add-coverage-report
run: uv run ./src/utils/scripts.py git_add_coverage_report
- name: Upload coverage
id: upload-coverage
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_TOKEN }}
files: ./cov-report/xml/cov-report.xml
verbose: true
build-package:
name: Build Package
needs: test
if: ${{ always() && needs.test.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v5
with:
ref: ${{ env.GIT_BRANCH }}
- name: Set up UV
uses: astral-sh/setup-uv@v6
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Check VERSION
id: check-version
run: |
if [ -z "${{ env.VERSION }}" ]; then
echo "/$VERSION is missing. Please try again."
exit 1
fi
- name: Install dependencies
run: uv sync --no-cache --upgrade --reinstall-package=${{ env.PACKAGE_NAME }}
- name: Setup Git
id: setup-git
run: |
uv run ./src/utils/scripts.py add_git_credentials
uv run ./src/utils/scripts.py git_switch_to_branch ${{ env.GIT_BRANCH }}
uv run ./src/utils/scripts.py git_refresh_current_branch
- name: Bump version
id: bump-version
run: uv version ${VERSION}
- name: Update Git Version
id: update-git-version
run: uv run ./src/utils/scripts.py git_update_version_cli ${VERSION}
- name: Build package
id: build-package
run: uv build --out-dir=dist
- name: Upload assets
id: upload-assets
uses: softprops/action-gh-release@v2
with:
files: dist/*
- name: Upload artifacts
id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*
retention-days: 5
overwrite: true
- name: Fix tag reference
id: fix-tag-reference
run: uv run ./src/utils/scripts.py git_fix_tag_reference_cli ${{ env.VERSION }}
deploy-package:
name: Deploy to PyPI
needs: build-package
if: ${{ always() && needs.build-package.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v5
with:
ref: ${{ env.GIT_BRANCH }}
- name: Set up UV
uses: astral-sh/setup-uv@v6
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Download artifacts
id: download-artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Publish package
id: publish-package
run: uv publish --token=${{ env.PYPI_TOKEN }} --no-cache dist/*
- name: Check
id: check
run: |
echo 'Package deployed to PyPI 👉 https://pypi.org/project/${{ env.PACKAGE_NAME }}'
uvx pip install --dry-run --no-deps --no-cache ${{ env.PACKAGE_NAME }}
install-package:
needs: deploy-package
if: ${{ always() && needs.deploy-package.result == 'success' }}
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
fail-fast: false
max-parallel: 30
name: Install Package on '${{ matrix.os }}' with '${{ matrix.python-version }}'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v5
with:
ref: ${{ env.GIT_BRANCH }}
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
id: install-package
run: pip install --no-cache --verbose --no-python-version-warning "${{ env.PACKAGE_NAME }}==${{ env.VERSION }}"
build-docs:
needs:
- test
- deploy-package
if: ${{ always() && needs.test.result == 'success' && needs.deploy-package.result == 'success' }}
name: Build Docs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout-repository
uses: actions/checkout@v5
with:
ref: ${{ env.GIT_BRANCH }}
- name: Set up UV
uses: astral-sh/setup-uv@v6
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
id: install-dependencies
run: uv sync --no-cache --upgrade --group=docs --reinstall-package=${{ env.PACKAGE_NAME}}
- name: Setup Git
id: setup-git
env:
GITHUB_ACTOR: ${{ github.actor }}
run: |
uv run ./src/utils/scripts.py add_git_credentials
uv run ./src/utils/scripts.py git_switch_to_branch ${{ env.GIT_BRANCH }}
uv run ./src/utils/scripts.py git_refresh_current_branch
- name: Generate ChangeLog
id: generate-changelog
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
run: uv run ./src/utils/changelog.py
- name: Commit ChangeLog
id: commit-changelog
run: |
git add .
git commit --message "Update changelog to \`${{ env.VERSION }}\` [skip ci]" || echo "No changes to commit"
git push --force --no-verify
git status
- name: Build docs
id: build-docs
run: uv run ./src/utils/scripts.py build_versioned_docs_cli ${{ env.VERSION }}
- name: Fix tag reference
id: fix-tag-reference
run: uv run ./src/utils/scripts.py git_fix_tag_reference_cli ${{ env.VERSION }}