Skip to content

Commit e8712bd

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 e8712bd

File tree

3 files changed

+442
-0
lines changed

3 files changed

+442
-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
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
# - Sanity checks:
32+
# - Version tag doesn't already exist
33+
# - Locate most recent release candidate tag.
34+
# - Apply final tag at same SHA as last RC.
35+
# - Create a draft GitHub release associated with the tag.
36+
# - Create and upload release artifacts of cmake install as per [FEA]: SHA Stable release URLs #622
37+
# - Notify team of results.
38+
39+
jobs:
40+
tag-release:
41+
runs-on: ubuntu-latest
42+
outputs:
43+
rc_tag: ${{ steps.prepare.outputs.rc_tag }}
44+
release_tag: ${{ steps.prepare.outputs.release_tag }}
45+
steps:
46+
- name: Checkout the repository
47+
uses: actions/checkout@v4
48+
with:
49+
persist-credentials: false
50+
- name: Prepare environment
51+
id: prepare
52+
run: |
53+
log_and_export_vars() {
54+
for var in "$@"; do
55+
var_name=${var^^}
56+
printf "%-15s %s\n" "$var_name:" "${!var}" | tee -a $GITHUB_STEP_SUMMARY
57+
echo "${var_name}=${!var}" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
58+
done
59+
}
60+
61+
full_version=${{ inputs.new_version }}
62+
major_version=$(echo ${full_version} | cut -d. -f1)
63+
minor_version=$(echo ${full_version} | cut -d. -f2)
64+
patch_version=$(echo ${full_version} | cut -d. -f3)
65+
release_tag="v${full_version}"
66+
release_tag_escaped=$(echo "${release_tag}" | sed 's/\./\\./g')
67+
68+
log_and_export_vars full_version major_version minor_version patch_version release_tag
69+
70+
# Ensure that there is no final release tag (vX.Y.Z) for the requested version.
71+
if git ls-remote --tags origin | grep -q "refs/tags/${release_tag_escaped}$"; then
72+
echo "::error::Tag ${release_tag} already exists."
73+
exit 1
74+
fi
75+
fi
76+
77+
# Look for previous release candidates:
78+
declare -i last_rc=
79+
for tag in $(git ls-remote --tags origin; do
80+
if [[ $tag =~ v${full_version}-rc([0-9]+)$ ]]; then
81+
rc=${BASH_REMATCH[1]}
82+
if (( rc > last_rc )); then
83+
last_rc=rc
84+
fi
85+
fi
86+
done
87+
88+
if [[ -z $last_rc ]]; then
89+
echo "::error::No release candidates found for version ${full_version}."
90+
fi
91+
92+
# Determine tag name
93+
rc_tag="v${full_version}-rc${last_rc}"
94+
95+
log_and_export_vars last_rc rc_tag
96+
97+
- name: Tag
98+
run: |
99+
git tag ${{ steps.prepare.outputs.release_tag }} ${{ steps.prepare.outputs.rc_tag }}
100+
git push origin ${{ steps.prepare.outputs.release_tag }}
101+
echo "Tagged release ${release_tag}."
102+
# TODO Notify team of results.

0 commit comments

Comments
 (0)