Skip to content

Commit cc966cd

Browse files
authored
backport release workflow to v11 (#420)
1 parent 569edf4 commit cc966cd

2 files changed

Lines changed: 180 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "CI: Upload git archive"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
git-tag:
7+
type: string
8+
required: true
9+
10+
concurrency:
11+
# Concurrency group that uses the workflow name and PR number if available
12+
# or commit SHA as a fallback. If a new build is triggered under that
13+
# concurrency group while a previous build is running it will be canceled.
14+
# Repeated pushes to a PR will cancel all previous builds, while multiple
15+
# merges to main will not cancel.
16+
group: ${{ github.workflow }}-${{ github.ref_name || github.sha }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
# create source archive and upload it to the published release
24+
# URL to the archive: https://github.com/NVIDIA/<repo>/releases/download/<tag>/<repo>-<tag>.tar.gz
25+
upload:
26+
if: ${{ !github.event.repository.fork }}
27+
runs-on: ubuntu-latest
28+
env:
29+
ARCHIVE_NAME: ${{ github.event.repository.name }}-${{ inputs.git-tag }}
30+
steps:
31+
- name: Checkout Source
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
ref: ${{ inputs.git-tag }}
36+
37+
- name: Create Release Directory
38+
run: mkdir -p release
39+
40+
- name: Archive Source
41+
run: >
42+
git archive
43+
--format=tar.gz
44+
--prefix="${{ env.ARCHIVE_NAME }}/"
45+
--output="release/${{ env.ARCHIVE_NAME }}.tar.gz"
46+
${{ inputs.git-tag }}
47+
48+
- name: Compute Checksum
49+
run: >
50+
sha256sum "release/${{ env.ARCHIVE_NAME }}.tar.gz"
51+
| awk '{print $1}'
52+
> "release/${{ env.ARCHIVE_NAME }}.tar.gz.sha256sum"
53+
54+
- name: Upload Archive
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
run: >
58+
gh release upload
59+
--clobber "${{ inputs.git-tag }}"
60+
--repo "${{ github.repository }}"
61+
release/*

.github/workflows/release.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: "CI: Release"
2+
3+
description: Manually-triggered release workflow. Must have a release note in the draft state and the release commit tagged.
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
component:
9+
description: "Component to release"
10+
required: true
11+
type: choice
12+
options:
13+
- cuda-core
14+
- cuda-bindings
15+
- cuda-python
16+
- all
17+
git-tag:
18+
description: "The release git tag"
19+
required: true
20+
type: string
21+
run-id:
22+
description: "The GHA run ID that generated validated artifacts"
23+
required: true
24+
type: string
25+
build-ctk-ver:
26+
type: string
27+
required: true
28+
wheel-dst:
29+
description: "Which wheel index to publish to?"
30+
required: true
31+
type: choice
32+
options:
33+
- testpypi
34+
- pypi
35+
36+
defaults:
37+
run:
38+
shell: bash --noprofile --norc -xeuo pipefail {0}
39+
40+
jobs:
41+
check-tag:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Check if draft exists for the tag
45+
env:
46+
GH_TOKEN: ${{ github.token }}
47+
run: |
48+
tags=
49+
for i in $(gh release list -R ${{ github.repository }} --json tagName --jq '.[]| .tagName'); do
50+
tags+=( $i )
51+
done
52+
is_draft=
53+
for i in $(gh release list -R ${{ github.repository }} --json isDraft --jq '.[]| .isDraft'); do
54+
is_draft+=( $i )
55+
done
56+
57+
found=0
58+
for idx in ${!tags[@]}; do
59+
if [[ "${tags[$idx]}" == "${{ inputs.git-tag }}" ]]; then
60+
echo "found ${{ inputs.git-tag }}"
61+
found=1
62+
if [[ "${is_draft[$idx]}" != "true" ]]; then
63+
echo "the release note is not in draft state"
64+
exit 1
65+
fi
66+
break
67+
fi
68+
done
69+
if [[ "$found" == 0 ]]; then
70+
echo "the release is not yet tagged"
71+
exit 1
72+
fi
73+
74+
upload-archive:
75+
name: Upload source archive
76+
permissions:
77+
contents: write
78+
needs:
79+
- check-tag
80+
secrets: inherit
81+
uses:
82+
./.github/workflows/release-upload.yml
83+
with:
84+
git-tag: ${{ inputs.git-tag }}
85+
86+
publish-wheels:
87+
name: Publish wheels
88+
runs-on: ubuntu-latest
89+
needs:
90+
- check-tag
91+
environment:
92+
name: ${{ inputs.wheel-dst }}
93+
url: https://${{ (inputs.wheel-dst == 'testpypi' && 'test.') || '' }}pypi.org/p/${{ inputs.component }}/
94+
permissions:
95+
id-token: write
96+
steps:
97+
- name: Download component wheels
98+
env:
99+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
run: |
101+
gh run download ${{ inputs.run-id }} -p "${{ inputs.component }}*" -R ${{ github.repository }}
102+
mkdir dist
103+
for p in ${{ inputs.component }}*
104+
do
105+
mv ${p}/*.whl dist/
106+
done
107+
rmdir ${{ inputs.component }}*
108+
109+
- name: Publish package distributions to PyPI
110+
if: ${{ inputs.wheel-dst == 'pypi' }}
111+
uses: pypa/gh-action-pypi-publish@release/v1
112+
113+
- name: Publish package distributions to TestPyPI
114+
if: ${{ inputs.wheel-dst == 'testpypi' }}
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
repository-url: https://test.pypi.org/legacy/
118+
119+
# TODO: add another job to make the release leave the draft state?

0 commit comments

Comments
 (0)