Skip to content

Commit 3d06a07

Browse files
committed
add a release workflow
1 parent b139e1f commit 3d06a07

File tree

2 files changed

+154
-10
lines changed

2 files changed

+154
-10
lines changed

.github/workflows/build-docs.yml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ on:
66
build-ctk-ver:
77
type: string
88
required: true
9+
component:
10+
description: "Component(s) to build docs for"
11+
required: true
12+
default: "all"
13+
type: choice
14+
options:
15+
- cuda-core
16+
- cuda-bindings
17+
- cuda-python
18+
- all
19+
git-tag:
20+
description: "Target git tag to build docs for"
21+
required: true
22+
default: ""
23+
type: string
24+
is-release:
25+
description: "Are we building release docs?"
26+
required: true
27+
default: false
28+
type: boolean
929

1030
jobs:
1131
build:
@@ -27,6 +47,7 @@ jobs:
2747
uses: actions/checkout@v4
2848
with:
2949
fetch-depth: 0
50+
ref: ${{ inputs.git-tag }}
3051

3152
# TODO: cache conda env to speed up the workflow once conda-incubator/setup-miniconda#267
3253
# is resolved
@@ -114,23 +135,40 @@ jobs:
114135
115136
pip install cuda_python*.whl
116137
117-
# This step sets the PR_NUMBER env var.
138+
# This step sets the PR_NUMBER/BUILD_LATEST/BUILD_PREVIEW env vars.
118139
- name: Get PR number
140+
if: ${{ !inputs.is-release }}
119141
uses: ./.github/actions/get_pr_number
120142

121-
- name: Build all (latest) docs
122-
id: build
143+
- name: Set up artifact directories
144+
run: |
145+
mkdir -p artifacts/docs
146+
# create an empty folder for removal use
147+
mkdir -p artifacts/empty_docs
148+
149+
- name: Build all docs
150+
if: ${{ inputs.component == 'all' }}
151+
env:
152+
DOC_ACTION: ${{ (inputs.is-release && '') || 'latest-only' }}
123153
run: |
124154
pushd cuda_python/docs/
125-
./build_all_docs.sh latest-only
155+
./build_all_docs.sh $DOC_ACTION
126156
ls -l build
127157
popd
128-
129-
mkdir -p artifacts/docs
130158
mv cuda_python/docs/build/html/* artifacts/docs/
131159
132-
# create an empty folder for removal use
133-
mkdir -p artifacts/empty_docs
160+
- name: Build component docs
161+
if: ${{ inputs.component != 'all' }}
162+
env:
163+
DOC_ACTION: ${{ (inputs.is-release && '') || 'latest-only' }}
164+
run: |
165+
COMPONENT=$(echo "${{ inputs.component }}" | tr '-' '_')
166+
pushd ${COMPONENT}/docs/
167+
./build_docs.sh $DOC_ACTION
168+
ls -l build
169+
rm -rf build/html/latest
170+
popd
171+
mv ${COMPONENT}/docs/build/html/* artifacts/docs/
134172
135173
# TODO: Consider removing this step?
136174
- name: Upload doc artifacts
@@ -140,19 +178,20 @@ jobs:
140178
retention-days: 3
141179

142180
- name: Deploy or clean up doc preview
181+
if: ${{ inputs.is-release }}
143182
uses: ./.github/actions/doc_preview
144183
with:
145184
source-folder: ${{ (github.ref_name != 'main' && 'artifacts/docs') ||
146185
'artifacts/empty_docs' }}
147186
pr-number: ${{ env.PR_NUMBER }}
148187

149188
- name: Deploy doc update
150-
if: ${{ github.ref_name == 'main' }}
189+
if: ${{ github.ref_name == 'main' || inputs.is-release }}
151190
uses: JamesIves/github-pages-deploy-action@v4
152191
with:
153192
git-config-name: cuda-python-bot
154193
git-config-email: [email protected]
155194
folder: artifacts/docs/
156195
target-folder: docs/
157-
commit-message: "Deploy latest docs: ${{ github.sha }}"
196+
commit-message: "Deploy ${{ (inputs.is-release && 'release') || 'latest' }} docs: ${{ github.sha }}"
158197
clean: false

.github/workflows/release.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
#print_tags:
29+
# description: 'True to print to STDOUT'
30+
# required: true
31+
# type: boolean
32+
33+
defaults:
34+
run:
35+
shell: bash --noprofile --norc -xeuo pipefail {0}
36+
37+
jobs:
38+
check-tag:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout ${{ github.event.repository.name }}
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Check if draft exists for the tag
47+
env:
48+
GH_TOKEN: ${{ github.token }}
49+
run: |
50+
tags=
51+
for i in $(gh release list -R ${{ github.repository }} --json tagName --jq '.[]| .tagName'); do
52+
tags+=( $i )
53+
done
54+
is_draft=
55+
for i in $(gh release list -R ${{ github.repository }} --json isDraft --jq '.[]| .isDraft'); do
56+
is_draft+=( $i )
57+
done
58+
59+
found=0
60+
for idx in ${!tags[@]}; do
61+
if [[ "${tags[$idx]}" == "${{ inputs.git-tag }}" ]]; then
62+
echo "found ${{ inputs.git-tag }}"
63+
found=1
64+
if [[ "${is_draft[$idx]}" != "true" ]]; then
65+
echo "the release note is not in draft state"
66+
exit 1
67+
fi
68+
break
69+
fi
70+
done
71+
if [[ "$found" == 0 ]]; then
72+
echo "the release is not yet tagged"
73+
exit 1
74+
fi
75+
76+
doc:
77+
name: Build release docs
78+
if: ${{ github.repository_owner == 'nvidia' }}
79+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
80+
permissions:
81+
id-token: write
82+
contents: write
83+
pull-requests: write
84+
needs:
85+
- check-tag
86+
secrets: inherit
87+
uses:
88+
./.github/workflows/build-docs.yml
89+
with:
90+
build-ctk-ver: ${{ inputs.build-ctk-ver }}
91+
component: ${{ inputs.component }}
92+
git-tag: ${{ inputs.git-tag }}
93+
is-release: true
94+
95+
upload-archive:
96+
name: Upload source archive
97+
permissions:
98+
contents: write
99+
needs:
100+
- check-tag
101+
secrets: inherit
102+
uses:
103+
./.github/workflows/release-upload.yml
104+
with:
105+
git-tag: ${{ inputs.git-tag }}

0 commit comments

Comments
 (0)