Skip to content

Commit 81475a2

Browse files
alliepiperwmaxey
authored andcommitted
Add release-update-rc.yml from NVIDIA#1945
1 parent b3fe77f commit 81475a2

File tree

1 file changed

+256
-0
lines changed

1 file changed

+256
-0
lines changed
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: "Release: 2. Test and Tag New RC"
17+
18+
# This workflow must be started on the "branch/{major}.{minor}.x" release branch
19+
# after the release-create-new workflow runs.
20+
21+
on:
22+
workflow_dispatch:
23+
24+
defaults:
25+
run:
26+
shell: bash --noprofile --norc -euo pipefail {0}
27+
28+
jobs:
29+
prepare:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
tag_name: ${{ steps.prepare.outputs.tag_name }}
33+
steps:
34+
- name: Checkout the repository
35+
uses: actions/checkout@v4
36+
with:
37+
persist-credentials: false
38+
39+
- name: Prepare environment
40+
id: prepare
41+
run: |
42+
log_vars() {
43+
for var in "$@"; do
44+
printf "%-15s %s\n" "${var}:" "${!var}" | tee -a $GITHUB_STEP_SUMMARY
45+
done
46+
}
47+
export_vars() {
48+
for var in "$@"; do
49+
echo "${var}=${!var}" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
50+
done
51+
}
52+
53+
# Parse repo version info:
54+
full_version=$(jq -r .full cccl-version.json)
55+
major_version=$(jq -r .major cccl-version.json)
56+
minor_version=$(jq -r .minor cccl-version.json)
57+
patch_version=$(jq -r .patch cccl-version.json)
58+
branch_name="branch/${major_version}.${minor_version}.x"
59+
60+
log_vars full_version major_version minor_version patch_version branch_name GITHUB_REF GITHUB_SHA
61+
export_vars full_version major_version minor_version patch_version branch_name
62+
63+
- name: Validate versions and tags
64+
run: |
65+
# The workflow must be started on a release branch:
66+
if [[ "${GITHUB_REF}" != "refs/heads/${branch_name}" ]]; then
67+
echo "::error::GITHUB_REF (${GITHUB_REF}) does not match expected branch name (${branch_name})."
68+
exit 1
69+
fi
70+
71+
# The release tag must not exist:
72+
full_version_escaped=$(echo "${full_version}" | sed 's/\./\\./g')
73+
if git ls-remote --tags origin | grep -q "refs/tags/v${full_version_escaped}\$"; then
74+
echo "::error::Tag v${full_version} already exists. Was the automated version-bump PR merged?"
75+
exit 1
76+
fi
77+
78+
# Look for previous release candidates:
79+
declare -i last_rc=-1
80+
for tag in $(git ls-remote --tags origin); do
81+
if [[ $tag =~ refs/tags/v${full_version_escaped}-rc([0-9]+)$ ]]; then
82+
echo "Found prior release candidate: ${tag}"
83+
rc=${BASH_REMATCH[1]}
84+
if (( rc > last_rc )); then
85+
last_rc=rc
86+
fi
87+
fi
88+
done
89+
90+
next_rc=$((last_rc + 1))
91+
tag_name="v${full_version}-rc${next_rc}"
92+
93+
log_vars last_rc next_rc tag_name
94+
export_vars tag_name
95+
96+
build-workflow:
97+
name: Build workflow from matrix
98+
runs-on: ubuntu-latest
99+
permissions:
100+
contents: read
101+
outputs:
102+
workflow: ${{ steps.build-workflow.outputs.workflow }}
103+
steps:
104+
- name: Checkout repo
105+
uses: actions/checkout@v4
106+
with:
107+
persist-credentials: false
108+
- name: Build workflow
109+
id: build-workflow
110+
uses: ./.github/actions/workflow-build
111+
with:
112+
workflows: pull_request #TODO could add more or create a new release_candidate approval workflow.
113+
slack_token: ${{ secrets.SLACK_NOTIFIER_BOT_TOKEN }}
114+
slack_log: ${{ secrets.SLACK_CHANNEL_RELEASE_LOG }}
115+
116+
dispatch-groups-linux-two-stage:
117+
name: ${{ matrix.name }}
118+
if: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['linux_two_stage']['keys']) != '[]' }}
119+
needs: build-workflow
120+
permissions:
121+
id-token: write
122+
contents: read
123+
strategy:
124+
fail-fast: false
125+
matrix:
126+
name: ${{ fromJSON(needs.build-workflow.outputs.workflow)['linux_two_stage']['keys'] }}
127+
uses: ./.github/workflows/workflow-dispatch-two-stage-group-linux.yml
128+
with:
129+
pc-array: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['linux_two_stage']['jobs'][matrix.name]) }}
130+
131+
dispatch-groups-windows-two-stage:
132+
name: ${{ matrix.name }}
133+
if: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['windows_two_stage']['keys']) != '[]' }}
134+
needs: build-workflow
135+
permissions:
136+
id-token: write
137+
contents: read
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
name: ${{ fromJSON(needs.build-workflow.outputs.workflow)['windows_two_stage']['keys'] }}
142+
uses: ./.github/workflows/workflow-dispatch-two-stage-group-windows.yml
143+
with:
144+
pc-array: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['windows_two_stage']['jobs'][matrix.name]) }}
145+
146+
dispatch-groups-linux-standalone:
147+
name: ${{ matrix.name }}
148+
if: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['linux_standalone']['keys']) != '[]' }}
149+
needs: build-workflow
150+
permissions:
151+
id-token: write
152+
contents: read
153+
strategy:
154+
fail-fast: false
155+
matrix:
156+
name: ${{ fromJSON(needs.build-workflow.outputs.workflow)['linux_standalone']['keys'] }}
157+
uses: ./.github/workflows/workflow-dispatch-standalone-group-linux.yml
158+
with:
159+
job-array: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['linux_standalone']['jobs'][matrix.name]) }}
160+
161+
dispatch-groups-windows-standalone:
162+
name: ${{ matrix.name }}
163+
if: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['windows_standalone']['keys']) != '[]' }}
164+
needs: build-workflow
165+
permissions:
166+
id-token: write
167+
contents: read
168+
strategy:
169+
fail-fast: false
170+
matrix:
171+
name: ${{ fromJSON(needs.build-workflow.outputs.workflow)['windows_standalone']['keys'] }}
172+
uses: ./.github/workflows/workflow-dispatch-standalone-group-windows.yml
173+
with:
174+
job-array: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)['windows_standalone']['jobs'][matrix.name]) }}
175+
176+
verify-workflow:
177+
name: Verify and summarize workflow results
178+
if: ${{ always() && !cancelled() }}
179+
needs:
180+
- build-workflow
181+
- dispatch-groups-linux-two-stage
182+
- dispatch-groups-windows-two-stage
183+
- dispatch-groups-linux-standalone
184+
- dispatch-groups-windows-standalone
185+
permissions:
186+
contents: read
187+
runs-on: ubuntu-latest
188+
steps:
189+
- name: Checkout repo
190+
uses: actions/checkout@v4
191+
with:
192+
persist-credentials: false
193+
194+
- name: Check workflow success
195+
id: check-workflow
196+
uses: ./.github/actions/workflow-results
197+
with:
198+
slack_token: ${{ secrets.SLACK_NOTIFIER_BOT_TOKEN }}
199+
slack_log: ${{ secrets.SLACK_CHANNEL_RELEASE_LOG }}
200+
201+
tag:
202+
needs:
203+
- prepare
204+
- verify-workflow
205+
permissions:
206+
contents: write
207+
runs-on: ubuntu-latest
208+
steps:
209+
- name: Checkout the repository
210+
uses: actions/checkout@v4
211+
with:
212+
persist-credentials: false
213+
214+
- name: Tag the release candidate
215+
run: |
216+
rc_tag=${{ needs.prepare.outputs.tag_name }}
217+
git tag -a -m "CCCL Release Candidate ${rc_tag}" ${rc_tag} ${GITHUB_SHA}
218+
git push origin ${rc_tag}
219+
echo "Tagged release candidate ${rc_tag}."
220+
221+
notify-success:
222+
if: ${{ success() }}
223+
needs: tag
224+
runs-on: ubuntu-latest
225+
steps:
226+
- name: Notify Slack
227+
uses: slackapi/slack-github-action@v1.26.0
228+
env:
229+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFIER_BOT_TOKEN }}
230+
SUMMARY_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
231+
RC_TAG: ${{ needs.prepare.outputs.tag_name }}
232+
with:
233+
channel-id: ${{ secrets.SLACK_CHANNEL_RELEASE_LOG }}
234+
slack-message: |
235+
A new release candidate `${{ env.RC_TAG }}` has been tagged.
236+
237+
Workflow summary: ${{ env.SUMMARY_URL }}
238+
239+
notify-failure:
240+
if: ${{ failure() }}
241+
needs: tag
242+
runs-on: ubuntu-latest
243+
steps:
244+
- name: Notify Slack (failure)
245+
if: ${{ failure() }}
246+
uses: slackapi/slack-github-action@v1.26.0
247+
env:
248+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFIER_BOT_TOKEN }}
249+
SUMMARY_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
250+
RC_TAG: ${{ needs.prepare.outputs.tag_name }}
251+
with:
252+
channel-id: ${{ secrets.SLACK_CHANNEL_RELEASE_LOG }}
253+
slack-message: |
254+
An error has occurred while creating release candidate `${{ env.RC_TAG }}`.
255+
256+
Details: ${{ env.SUMMARY_URL }}

0 commit comments

Comments
 (0)