forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
384 lines (352 loc) · 13.8 KB
/
release-cuda-pathfinder.yml
File metadata and controls
384 lines (352 loc) · 13.8 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
# One-click release workflow for cuda-pathfinder.
#
# Provide a release tag. The workflow finds
# the CI run, creates a draft GitHub release with the standard
# body, builds versioned docs, uploads source archive + wheels to the
# release, publishes to TestPyPI, verifies the install, publishes to PyPI,
# verifies again, and finally marks the release as published.
name: "Release: cuda-pathfinder"
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (e.g. cuda-pathfinder-v1.3.5)"
required: true
type: string
concurrency:
group: release-cuda-pathfinder
cancel-in-progress: false
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
jobs:
# --------------------------------------------------------------------------
# Collect release metadata, find the CI run, create a draft release.
# --------------------------------------------------------------------------
prepare:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.vars.outputs.tag }}
version: ${{ steps.vars.outputs.version }}
run-id: ${{ steps.detect-run.outputs.run-id }}
steps:
- name: Verify running on default branch
run: |
if [[ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]]; then
echo "::error::This workflow must be triggered from the default branch (${{ github.event.repository.default_branch }}). Got: ${{ github.ref_name }} (select the correct branch in the 'Use workflow from' dropdown)."
exit 1
fi
- name: Set release variables
id: vars
env:
TAG_INPUT: ${{ inputs.tag }}
run: |
version="${TAG_INPUT#cuda-pathfinder-v}"
{
echo "tag=${TAG_INPUT}"
echo "version=${version}"
} >> "$GITHUB_OUTPUT"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Resolve only the exact tag ref; checkout fails if the tag does not exist.
ref: refs/tags/${{ steps.vars.outputs.tag }}
- name: Check release notes exist
env:
VERSION: ${{ steps.vars.outputs.version }}
run: |
notes="cuda_pathfinder/docs/source/release/${VERSION}-notes.rst"
if [[ ! -f "${notes}" ]]; then
echo "::error::Release notes not found: ${notes}"
echo "Create the release notes file before running this workflow."
exit 1
fi
- name: Detect CI run ID
id: detect-run
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.vars.outputs.tag }}
run: |
run_id=$(./ci/tools/lookup-run-id "${TAG}" "${{ github.repository }}")
echo "run-id=${run_id}" >> "$GITHUB_OUTPUT"
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.vars.outputs.tag }}
VERSION: ${{ steps.vars.outputs.version }}
run: |
# If the release exists and is already published, stop early.
existing_draft=$(gh release view "${TAG}" --repo "${{ github.repository }}" --json isDraft --jq '.isDraft' 2>/dev/null || echo "missing")
if [[ "${existing_draft}" == "false" ]]; then
echo "::error::Release ${TAG} already exists and is published. Cannot re-release."
exit 1
fi
if [[ "${existing_draft}" == "true" ]]; then
exit 0
fi
cat > /tmp/release-body.md <<BODY
## Release notes
- https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/release/${VERSION}-notes.html
## Documentation
- https://nvidia.github.io/cuda-python/cuda-pathfinder/${VERSION}/
## PyPI
- https://pypi.org/project/cuda-pathfinder/${VERSION}/
## Conda
- https://anaconda.org/conda-forge/cuda-pathfinder/files?version=${VERSION}
- \`conda install conda-forge::cuda-pathfinder=${VERSION}\`
BODY
gh release create "${TAG}" \
--repo "${{ github.repository }}" \
--draft \
--latest=false \
--verify-tag \
--title "cuda-pathfinder v${VERSION}" \
--notes-file /tmp/release-body.md
# --------------------------------------------------------------------------
# Build and deploy versioned docs.
# --------------------------------------------------------------------------
docs:
needs: prepare
if: ${{ github.repository_owner == 'nvidia' }}
permissions:
id-token: write
contents: write
pull-requests: write
secrets: inherit
uses: ./.github/workflows/build-docs.yml
with:
component: cuda-pathfinder
git-tag: ${{ needs.prepare.outputs.tag }}
run-id: ${{ needs.prepare.outputs.run-id }}
is-release: true
# --------------------------------------------------------------------------
# Upload source archive and wheels to the GitHub release.
# Runs even if docs fail -- assets are independent and the finalize
# job's docs-URL check will warn if docs aren't deployed yet.
# --------------------------------------------------------------------------
upload-assets:
needs: [prepare, docs]
if: ${{ !cancelled() && needs.prepare.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
env:
TAG: ${{ needs.prepare.outputs.tag }}
RUN_ID: ${{ needs.prepare.outputs.run-id }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ needs.prepare.outputs.tag }}
- name: Create source archive
run: |
archive="${{ github.event.repository.name }}-${TAG}"
mkdir -p release
git archive \
--format=tar.gz \
--prefix="${archive}/" \
--output="release/${archive}.tar.gz" \
"${TAG}"
sha256sum "release/${archive}.tar.gz" \
| awk '{print $1}' > "release/${archive}.tar.gz.sha256sum"
- name: Download wheels
env:
GH_TOKEN: ${{ github.token }}
run: |
./ci/tools/download-wheels "${RUN_ID}" "cuda-pathfinder" "${{ github.repository }}" "release/wheels"
- name: Upload to release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${TAG}" \
--repo "${{ github.repository }}" \
--clobber \
release/*.tar.gz release/*.sha256sum release/wheels/*.whl
# --------------------------------------------------------------------------
# Publish to TestPyPI.
# --------------------------------------------------------------------------
publish-testpypi:
needs: [prepare, docs]
if: ${{ !cancelled() && needs.prepare.result == 'success' }}
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/cuda-pathfinder/
permissions:
id-token: write
env:
RUN_ID: ${{ needs.prepare.outputs.run-id }}
steps:
- name: Download wheels
env:
GH_TOKEN: ${{ github.token }}
run: |
# Intentionally inline artifact download logic here so publish jobs
# are pinned only to RUN_ID artifacts and do not depend on repo checkout.
mkdir -p dist
gh run download "${RUN_ID}" -p "cuda-pathfinder*" -R "${{ github.repository }}"
shopt -s nullglob globstar
for artifact_dir in cuda-*; do
if [[ ! -d "${artifact_dir}" ]]; then
continue
fi
if [[ "${artifact_dir}" == *-tests ]]; then
continue
fi
wheels=( "${artifact_dir}"/**/*.whl )
if (( ${#wheels[@]} > 0 )); then
mv "${wheels[@]}" dist/
fi
done
rm -rf cuda-*
ls -la dist
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
# --------------------------------------------------------------------------
# Verify the TestPyPI package installs and imports correctly.
# --------------------------------------------------------------------------
verify-testpypi:
needs: [prepare, publish-testpypi]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Install from TestPyPI and verify
run: |
python3 -m venv /tmp/verify
source /tmp/verify/bin/activate
max_attempts=6
retry_seconds=30
for ((attempt=1; attempt<=max_attempts; attempt++)); do
if pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
"cuda-pathfinder==${VERSION}"; then
break
fi
if (( attempt == max_attempts )); then
echo "::error::Failed to install cuda-pathfinder==${VERSION} from TestPyPI after ${max_attempts} attempts"
exit 1
fi
sleep "${retry_seconds}"
done
installed=$(python -c "from cuda.pathfinder import __version__; print(__version__)")
if [[ "${installed}" != "${VERSION}" ]]; then
echo "::error::Version mismatch: expected ${VERSION}, got ${installed}"
exit 1
fi
# --------------------------------------------------------------------------
# Publish to PyPI.
# --------------------------------------------------------------------------
publish-pypi:
needs: [prepare, verify-testpypi]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/cuda-pathfinder/
permissions:
id-token: write
env:
RUN_ID: ${{ needs.prepare.outputs.run-id }}
steps:
- name: Download wheels
env:
GH_TOKEN: ${{ github.token }}
run: |
# Intentionally inline artifact download logic here so publish jobs
# are pinned only to RUN_ID artifacts and do not depend on repo checkout.
mkdir -p dist
gh run download "${RUN_ID}" -p "cuda-pathfinder*" -R "${{ github.repository }}"
shopt -s nullglob globstar
for artifact_dir in cuda-*; do
if [[ ! -d "${artifact_dir}" ]]; then
continue
fi
if [[ "${artifact_dir}" == *-tests ]]; then
continue
fi
wheels=( "${artifact_dir}"/**/*.whl )
if (( ${#wheels[@]} > 0 )); then
mv "${wheels[@]}" dist/
fi
done
rm -rf cuda-*
ls -la dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
# --------------------------------------------------------------------------
# Verify the PyPI package installs and imports correctly.
# --------------------------------------------------------------------------
verify-pypi:
needs: [prepare, publish-pypi]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Install from PyPI and verify
run: |
python3 -m venv /tmp/verify
source /tmp/verify/bin/activate
max_attempts=6
retry_seconds=30
for ((attempt=1; attempt<=max_attempts; attempt++)); do
if pip install "cuda-pathfinder==${VERSION}"; then
break
fi
if (( attempt == max_attempts )); then
echo "::error::Failed to install cuda-pathfinder==${VERSION} from PyPI after ${max_attempts} attempts"
exit 1
fi
sleep "${retry_seconds}"
done
installed=$(python -c "from cuda.pathfinder import __version__; print(__version__)")
if [[ "${installed}" != "${VERSION}" ]]; then
echo "::error::Version mismatch: expected ${VERSION}, got ${installed}"
exit 1
fi
# --------------------------------------------------------------------------
# Verify docs and publish the release (mark non-draft).
# --------------------------------------------------------------------------
finalize:
needs: [prepare, verify-pypi, upload-assets]
runs-on: ubuntu-latest
permissions:
contents: write
env:
TAG: ${{ needs.prepare.outputs.tag }}
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Verify docs URL
run: |
url="https://nvidia.github.io/cuda-python/cuda-pathfinder/${VERSION}/"
status=$(curl -sL -o /dev/null -w '%{http_code}' "${url}")
if [[ "${status}" != "200" ]]; then
echo "::warning::Docs URL returned HTTP ${status} -- docs may not be deployed yet"
fi
- name: Verify release is still a draft
env:
GH_TOKEN: ${{ github.token }}
run: |
is_draft=$(gh release view "${TAG}" --repo "${{ github.repository }}" --json isDraft --jq '.isDraft')
if [[ "${is_draft}" != "true" ]]; then
echo "::error::Release ${TAG} is no longer a draft (was it published manually?)"
exit 1
fi
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release edit "${TAG}" \
--repo "${{ github.repository }}" \
--draft=false \
--latest=false
docs_url="https://nvidia.github.io/cuda-python/cuda-pathfinder/${VERSION}/"
echo "${docs_url}"
printf '%s\n' "${docs_url}" >> "$GITHUB_STEP_SUMMARY"