Skip to content

Commit abef10a

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`. - Commits version bump to release branch. - Creates pull request to merge the release branch into `main`. - `release-update-rc`: Validate and tag a new release candidate. - Inputs: - `new_version`: The new version, eg. "2.3.1" - `ref`: Optional; The ref to tag as the release candidate. If not provided, the current HEAD of the release branch is used. - Actions: - 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 abef10a

File tree

3 files changed

+434
-0
lines changed

3 files changed

+434
-0
lines changed
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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: Begin New Release"
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
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+
git checkout $BRANCH_NAME
72+
else
73+
git checkout ${{inputs.branch_point}}
74+
git checkout -b $BRANCH_NAME
75+
fi
76+
77+
- name: Update version numbers
78+
run: |
79+
./ci/update-version.sh ${MAJOR_VERSION} ${MINOR_VERSION} ${PATCH_VERSION}
80+
git diff
81+
git add .
82+
git commit -m "Bump version to ${FULL_VERSION}."
83+
84+
- name: Update upstream release branch
85+
run: |
86+
git push origin $BRANCH_NAME:$BRANCH_NAME
87+
88+
- name: Create a pull request
89+
uses: peter-evans/create-pull-request@v5
90+
with:
91+
branch: ${{ steps.prepare-env.outputs.BRANCH_NAME }}
92+
title: 'Merge release ${{ steps.prepare-env.outputs.FULL_VERSION }} into main'
93+
body: 'This PR updates the version numbers to ${{ steps.prepare-env.outputs.FULL_VERSION }}.'
94+
base: main
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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: Publish 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+
outputs:
34+
rc_tag: ${{ steps.prepare.outputs.rc_tag }}
35+
release_tag: ${{ steps.prepare.outputs.release_tag }}
36+
steps:
37+
- name: Checkout the repository
38+
uses: actions/checkout@v4
39+
with:
40+
persist-credentials: false
41+
- name: Prepare environment
42+
id: prepare
43+
run: |
44+
log_and_export_vars() {
45+
for var in "$@"; do
46+
var_name=${var^^}
47+
printf "%-15s %s\n" "$var_name:" "${!var}" | tee -a $GITHUB_STEP_SUMMARY
48+
echo "${var_name}=${!var}" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
49+
done
50+
}
51+
52+
full_version=${{ inputs.new_version }}
53+
major_version=$(echo ${full_version} | cut -d. -f1)
54+
minor_version=$(echo ${full_version} | cut -d. -f2)
55+
patch_version=$(echo ${full_version} | cut -d. -f3)
56+
release_tag="v${full_version}"
57+
release_tag_escaped=$(echo "${release_tag}" | sed 's/\./\\./g')
58+
59+
log_and_export_vars full_version major_version minor_version patch_version release_tag
60+
61+
# Ensure that there is no final release tag (vX.Y.Z) for the requested version.
62+
if git ls-remote --tags origin | grep -q "refs/tags/${release_tag_escaped}$"; then
63+
echo "::error::Tag ${release_tag} already exists."
64+
exit 1
65+
fi
66+
fi
67+
68+
# Look for previous release candidates:
69+
declare -i last_rc=
70+
for tag in $(git ls-remote --tags origin; do
71+
if [[ $tag =~ v${full_version}-rc([0-9]+)$ ]]; then
72+
rc=${BASH_REMATCH[1]}
73+
if (( rc > last_rc )); then
74+
last_rc=rc
75+
fi
76+
fi
77+
done
78+
79+
if [[ -z $last_rc ]]; then
80+
echo "::error::No release candidates found for version ${full_version}."
81+
fi
82+
83+
# Determine tag name
84+
rc_tag="v${full_version}-rc${last_rc}"
85+
86+
log_and_export_vars last_rc rc_tag
87+
88+
- name: Tag
89+
run: |
90+
git tag ${{ steps.prepare.outputs.release_tag }} ${{ steps.prepare.outputs.rc_tag }}
91+
git push origin ${{ steps.prepare.outputs.release_tag }}
92+
echo "Tagged release ${release_tag}."
93+
# TODO Notify team of results.

0 commit comments

Comments
 (0)