-
Notifications
You must be signed in to change notification settings - Fork 277
119 lines (109 loc) · 3.29 KB
/
release.yml
File metadata and controls
119 lines (109 loc) · 3.29 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
name: "CI: Release"
description: Manually-triggered release workflow. Must have a release note in the draft state and the release commit tagged.
on:
workflow_dispatch:
inputs:
component:
description: "Component to release"
required: true
type: choice
options:
- cuda-core
- cuda-bindings
- cuda-python
- all
git-tag:
description: "The release git tag"
required: true
type: string
run-id:
description: "The GHA run ID that generated validated artifacts"
required: true
type: string
build-ctk-ver:
type: string
required: true
wheel-dst:
description: "Which wheel index to publish to?"
required: true
type: choice
options:
- testpypi
- pypi
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
jobs:
check-tag:
runs-on: ubuntu-latest
steps:
- name: Check if draft exists for the tag
env:
GH_TOKEN: ${{ github.token }}
run: |
tags=
for i in $(gh release list -R ${{ github.repository }} --json tagName --jq '.[]| .tagName'); do
tags+=( $i )
done
is_draft=
for i in $(gh release list -R ${{ github.repository }} --json isDraft --jq '.[]| .isDraft'); do
is_draft+=( $i )
done
found=0
for idx in ${!tags[@]}; do
if [[ "${tags[$idx]}" == "${{ inputs.git-tag }}" ]]; then
echo "found ${{ inputs.git-tag }}"
found=1
if [[ "${is_draft[$idx]}" != "true" ]]; then
echo "the release note is not in draft state"
exit 1
fi
break
fi
done
if [[ "$found" == 0 ]]; then
echo "the release is not yet tagged"
exit 1
fi
upload-archive:
name: Upload source archive
permissions:
contents: write
needs:
- check-tag
secrets: inherit
uses:
./.github/workflows/release-upload.yml
with:
git-tag: ${{ inputs.git-tag }}
publish-wheels:
name: Publish wheels
runs-on: ubuntu-latest
needs:
- check-tag
environment:
name: ${{ inputs.wheel-dst }}
url: https://${{ (inputs.wheel-dst == 'testpypi' && 'test.') || '' }}pypi.org/p/${{ inputs.component }}/
permissions:
id-token: write
steps:
- name: Download component wheels
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run download ${{ inputs.run-id }} -p "${{ inputs.component }}*" -R ${{ github.repository }}
mkdir dist
for p in ${{ inputs.component }}*
do
mv ${p}/*.whl dist/
done
rmdir ${{ inputs.component }}*
- name: Publish package distributions to PyPI
if: ${{ inputs.wheel-dst == 'pypi' }}
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish package distributions to TestPyPI
if: ${{ inputs.wheel-dst == 'testpypi' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# TODO: add another job to make the release leave the draft state?