Skip to content

Commit 37fa33a

Browse files
committed
Add release automation workflows.
Fixes NVIDIA#653. Adds three new workflows that can be manually triggered at various points in the release process: - `release-create-new`: Begin the release process for a new version. - Inputs: - `new_version`: The new version, eg. "2.3.1" - `branch_point`: Optional; If the `branch/{major}.{minor}.x` branch does not exist, create it from this SHA. If the release branch already exists, this is ignored. If not provided, the release branch is created from the current `main` branch. - Actions: - Creates release branch if needed. - Bumps version numbers with `update-version.sh` in topic branch. - Creates pull request to merge the topic branch into `main` - Marks the pull request for backporting to the release branch. - `release-update-rc`: Validate and tag a new release candidate. - Inputs: - `new_version`: The new version, eg. "2.3.1" - Actions: - Uses the HEAD SHA of the release branch for testing/tagging. - Determines the next rc for this version by inspecting existing tags. - Runs the `pull_request` workflow to validate the release candidate. This can be modified in the future to run a special rc acceptance workflow. - Tags the release candidate if the workflow passes. - `release-finalize`: Tag a final release. - Inputs: - `new_version`: The new version, eg. "2.3.1" - Actions: - Determines the most recent release candidate. - Tags the latest release candidate as the final release. [skip-matrix][skip-rapids][skip-vdc][skip-docs]
1 parent 2f8aa7d commit 37fa33a

File tree

3 files changed

+422
-0
lines changed

3 files changed

+422
-0
lines changed
+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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: 1. Begin Release Cycle"
17+
18+
on:
19+
workflow_dispatch:
20+
inputs:
21+
new_version:
22+
description: "Semantic version string (eg. '2.3.0')"
23+
type: string
24+
required: true
25+
branch_point:
26+
description: "If the release branch doesn't exist yet, it will be branched from this ref."
27+
type: string
28+
required: true
29+
default: 'main'
30+
31+
defaults:
32+
run:
33+
shell: bash --noprofile --norc -euo pipefail {0}
34+
35+
jobs:
36+
create-release-branch:
37+
permissions:
38+
contents: write
39+
pull-requests: write
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Prepare environment
43+
id: prepare-env
44+
run: |
45+
log_and_export_vars() {
46+
for var in "$@"; do
47+
var_name=${var^^}
48+
printf "%-15s %s\n" "$var_name:" "${!var}" | tee -a $GITHUB_STEP_SUMMARY
49+
echo "${var_name}=${!var}" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
50+
done
51+
}
52+
53+
full_version=${{ inputs.new_version }}
54+
major_version=$(echo ${full_version} | cut -d. -f1)
55+
minor_version=$(echo ${full_version} | cut -d. -f2)
56+
patch_version=$(echo ${full_version} | cut -d. -f3)
57+
branch_name="branch/${major_version}.${minor_version}.x"
58+
59+
log_and_export_vars full_version major_version minor_version patch_version branch_name
60+
61+
- name: Checkout the repository
62+
uses: actions/checkout@v4
63+
with:
64+
persist-credentials: false
65+
66+
- name: Create release branch if needed
67+
id: create_branch
68+
run: |
69+
# Create the release branch if it doesn't already exist:
70+
if git ls-remote --exit-code origin $BRANCH_NAME; then
71+
echo "Branch $BRANCH_NAME already exists." | tee -a $GITHUB_STEP_SUMMARY
72+
else
73+
git checkout ${{inputs.branch_point}}
74+
git checkout -b $BRANCH_NAME
75+
git push origin $BRANCH_NAME:$BRANCH_NAME
76+
echo "Created branch $BRANCH_NAME at:\n$(git show HEAD)" | tee -a $GITHUB_STEP_SUMMARY
77+
fi
78+
79+
- name: Update version numbers
80+
run: |
81+
git checkout main
82+
git checkout -b bump_version_${major_version}.${minor_version}.${patch_version}
83+
84+
echo "::group::Running update-version.sh"
85+
./ci/update-version.sh ${MAJOR_VERSION} ${MINOR_VERSION} ${PATCH_VERSION}
86+
echo "::endgroup::"
87+
88+
echo "::group::Diff"
89+
git diff
90+
echo "::endgroup::"
91+
92+
git add .
93+
git commit -m "Bump version to ${FULL_VERSION}."
94+
95+
- name: Create a pull request
96+
id: create_pr
97+
uses: peter-evans/create-pull-request@v5
98+
with:
99+
branch: ${{ steps.prepare-env.outputs.BRANCH_NAME }}
100+
title: 'Bump version to ${{ steps.prepare-env.outputs.FULL_VERSION }}'
101+
body: 'This PR was automatically generated by the release-create-new workflow.'
102+
base: main
103+
104+
- name: Add backport comment
105+
run: |
106+
echo "/backport $BRANCH_NAME" | gh issue comment ${{ steps.create_pr.outputs.pull-request-number }} -F -
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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: 3. Tag Final Release"
17+
18+
on:
19+
workflow_dispatch:
20+
inputs:
21+
new_version:
22+
type: string
23+
description: "Semantic version string (eg. '2.3.0')"
24+
required: true
25+
26+
defaults:
27+
run:
28+
shell: bash --noprofile --norc -euo pipefail {0}
29+
30+
jobs:
31+
tag-release:
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: write
35+
outputs:
36+
rc_tag: ${{ steps.prepare.outputs.rc_tag }}
37+
release_tag: ${{ steps.prepare.outputs.release_tag }}
38+
steps:
39+
- name: Checkout the repository
40+
uses: actions/checkout@v4
41+
with:
42+
persist-credentials: false
43+
- name: Prepare environment
44+
id: prepare
45+
run: |
46+
log_and_export_vars() {
47+
for var in "$@"; do
48+
var_name=${var^^}
49+
printf "%-15s %s\n" "$var_name:" "${!var}" | tee -a $GITHUB_STEP_SUMMARY
50+
echo "${var_name}=${!var}" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
51+
done
52+
}
53+
54+
full_version=${{ inputs.new_version }}
55+
major_version=$(echo ${full_version} | cut -d. -f1)
56+
minor_version=$(echo ${full_version} | cut -d. -f2)
57+
patch_version=$(echo ${full_version} | cut -d. -f3)
58+
release_tag="v${full_version}"
59+
release_tag_escaped=$(echo "${release_tag}" | sed 's/\./\\./g')
60+
61+
log_and_export_vars full_version major_version minor_version patch_version release_tag
62+
63+
# Ensure that there is no final release tag (vX.Y.Z) for the requested version.
64+
if git ls-remote --tags origin | grep -q "refs/tags/${release_tag_escaped}$"; then
65+
echo "::error::Tag ${release_tag} already exists."
66+
exit 1
67+
fi
68+
fi
69+
70+
# Look for previous release candidates:
71+
declare -i last_rc=
72+
for tag in $(git ls-remote --tags origin; do
73+
if [[ $tag =~ v${full_version}-rc([0-9]+)$ ]]; then
74+
rc=${BASH_REMATCH[1]}
75+
if (( rc > last_rc )); then
76+
last_rc=rc
77+
fi
78+
fi
79+
done
80+
81+
if [[ -z $last_rc ]]; then
82+
echo "::error::No release candidates found for version ${full_version}."
83+
fi
84+
85+
# Determine tag name
86+
rc_tag="v${full_version}-rc${last_rc}"
87+
88+
log_and_export_vars last_rc rc_tag
89+
90+
- name: Tag
91+
run: |
92+
git tag ${{ steps.prepare.outputs.release_tag }} ${{ steps.prepare.outputs.rc_tag }}
93+
git push origin ${{ steps.prepare.outputs.release_tag }}
94+
echo "Tagged release ${release_tag}."
95+
# TODO Notify team of results.

0 commit comments

Comments
 (0)