Skip to content

Commit cfd7cc3

Browse files
authored
Merge pull request #1486 from elezar/update-release-tooling
Update release tooling
2 parents 6d78f0d + 89d2dbd commit cfd7cc3

File tree

3 files changed

+77
-127
lines changed

3 files changed

+77
-127
lines changed

RELEASE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ The NVIDIA Container Toolkit consists of the following artifacts:
77

88
# Release Process Checklist:
99
- [ ] Create a release PR:
10-
- [ ] Run the `./hack/prepare-release.sh` script to update the version in all the needed files. This also creates a [release issue](https://github.com/NVIDIA/cloud-native-team/issues?q=is%3Aissue+is%3Aopen+label%3Arelease)
10+
- [ ] Run the `./hack/prepare-release.sh` script to update the version in all the needed files. This also creates a [release issue](https://github.com/NVIDIA/nvidia-container-toolkit/issues?q=is%3Aissue+is%3Aopen+label%3Arelease)
1111
- [ ] Run the `./hack/generate-changelog.sh` script to generate the a draft changelog and update `CHANGELOG.md` with the changes.
1212
- [ ] Create a PR from the created `bump-release-{{ .VERSION }}` branch.
1313
- [ ] Merge the release PR
1414
- [ ] Tag the release and push the tag to the `internal` mirror:
15-
- [ ] Image release pipeline: https://gitlab-master.nvidia.com/dl/container-dev/container-toolkit/-/pipelines/16466098
1615
- [ ] Wait for the image release to complete.
1716
- [ ] Push the tag to the the upstream GitHub repo.
18-
- [ ] Wait for the [`Release`](https://github.com/NVIDIA/k8s-device-plugin/actions/workflows/release.yaml) GitHub Action to complete
19-
- [ ] Publish the [draft release](https://github.com/NVIDIA/k8s-device-plugin/releases) created by the GitHub Action
17+
- [ ] Wait for the [`Release`](https://github.com/NVIDIA/nvidia-container-toolkit/actions/workflows/release.yaml) GitHub Action to complete
18+
- [ ] Publish the [draft release](https://github.com/NVIDIA/nvidia-container-toolkit/releases) created by the GitHub Action
2019
- [ ] Publish the packages to the gh-pages branch of the libnvidia-container repo
2120
- [ ] Create a KitPick
21+
- [ ] For non-experimental releases, schedule the package for publication to the CUDA Downloads repositories.
2222

2323
## Troubleshooting
2424

hack/generate-changelog.sh

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ this=`basename $0`
1919

2020
usage () {
2121
cat << EOF
22-
Generate a changelog for the specified tag
23-
Usage: $this --reference <tag> [--remote <remote_name>]
22+
Generate a changelog for an NVIDIA Container Toolkit release
23+
24+
Usage: $this [-h] --previous-version <previous_version> --version <version>
2425
2526
Options:
26-
--since specify the tag to start the changelog from (default: latest tag)
27-
--version specify the version to be released
27+
--previous-version specify the previous version
28+
--version specify the version for this release.
2829
--help/-h show this help and exit
2930
3031
EOF
@@ -33,26 +34,24 @@ EOF
3334
LIB_VERSION=$(awk -F= '/^LIB_VERSION/ { print $2 }' versions.mk | tr -d '[:space:]')
3435
LIB_TAG=$(awk -F= '/^LIB_TAG/ { print $2 }' versions.mk | tr -d '[:space:]')
3536

36-
VERSION="v${LIB_VERSION}${LIB_TAG:+-${LIB_TAG}}"
37-
>&2 echo "VERSION=$VERSION"
38-
39-
REFERENCE=
37+
version="v${LIB_VERSION}${LIB_TAG:+-${LIB_TAG}}"
38+
>&2 echo "version=$version"
4039

40+
previous_version=
4141
# Parse command line options
4242
while [[ $# -gt 0 ]]; do
4343
key="$1"
4444
case $key in
45-
--since)
46-
REFERENCE="$2"
47-
shift # past argument
48-
shift # past value
45+
--previous-version)
46+
previous_version="$2"
47+
shift 2
4948
;;
5049
--version)
51-
VERSION="$2"
52-
shift # past argument
53-
shift # past value
50+
version="$2"
51+
shift 2
5452
;;
55-
--help/-h) usage
53+
--help/-h)
54+
usage
5655
exit 0
5756
;;
5857
*) usage
@@ -61,44 +60,47 @@ while [[ $# -gt 0 ]]; do
6160
esac
6261
done
6362

63+
# Check that no extra args were provided
64+
if [ -z "$release" ]; then
65+
echo -e "ERROR: --version is required"
66+
usage
67+
exit 1
68+
fi
69+
70+
if [ -z ${previous_version} ]; then
71+
echo -e "ERROR: --previous-version is required"
72+
usage
73+
exit 1
74+
fi
75+
6476
# Fetch the latest tags from the remote
6577
remote=$( git remote -v | grep -E "NVIDIA/nvidia-container-toolkit(\.git)?\s" | grep -oE "^[a-z]+" | sort -u )
6678
>&2 echo "Detected remote as '${remote}'"
6779
git fetch ${remote} --tags
6880

69-
SHA=$(git rev-parse ${VERSION})
81+
SHA=$(git rev-parse ${version})
7082
if [[ $? -ne 0 ]]; then
7183
SHA="HEAD"
7284
fi
7385

74-
# if REFERENCE is not set, get the latest tag
75-
if [ -z "$REFERENCE" ]; then
76-
most_recent_tag=$(git tag --sort=-creatordate | head -1)
77-
if [ "${VERSION}" == "${most_recent_tag}" ]; then
78-
REFERENCE=$(git tag --sort=-creatordate | head -2 | tail -1)
79-
else
80-
REFERENCE=${most_recent_tag}
81-
fi
82-
fi
83-
84-
>&2 echo "Using ${REFERENCE} as previous version"
86+
>&2 echo "Using ${previous_version} as previous version"
8587

8688
# Print the changelog
8789
echo "## What's Changed"
8890
echo ""
89-
if [[ ${VERSION} != v*-rc.* ]]; then
90-
echo "- Promote $REFERENCE to $VERSION"
91+
if [[ ${version} != v*-rc.* && ${previous_version} == v*-rc.* ]]; then
92+
echo "- Promote ${previous_version} to $version"
9193
fi
9294

9395
# Iterate over the commit messages and ignore the ones that start with "Merge" or "Bump"
94-
git log --pretty=format:"%s" $REFERENCE..$SHA -- ':!deployments/container' ':!tools' | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
96+
git log --pretty=format:"%s" ${previous_version}..$SHA -- ':!deployments/container' ':!tools' | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
9597

9698
echo ""
9799
echo "### Changes in the Toolkit Container"
98100
echo ""
99-
git log --pretty=format:"%s" $REFERENCE..$SHA -- deployments/container tools | grep -Ev "(^Merge )|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
101+
git log --pretty=format:"%s" ${previous_version}..$SHA -- deployments/container tools | grep -Ev "(^Merge )|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
100102

101-
LIB_NVIDIA_CONTAINER_REFERENCE=$( git ls-tree $REFERENCE third_party/libnvidia-container --object-only )
103+
LIB_NVIDIA_CONTAINER_REFERENCE=$( git ls-tree ${previous_version} third_party/libnvidia-container --object-only )
102104
LIB_NVIDIA_CONTAINER_VERSION=$( git ls-tree $SHA third_party/libnvidia-container --object-only )
103105

104106
echo ""
@@ -109,5 +111,5 @@ git -C third_party/libnvidia-container log --pretty=format:"%s" $LIB_NVIDIA_CONT
109111
echo ""
110112
fi
111113

112-
echo "**Full Changelog**: https://github.com/NVIDIA/nvidia-container-toolkit/compare/${REFERENCE}...${VERSION}"
114+
echo "**Full Changelog**: https://github.com/NVIDIA/nvidia-container-toolkit/compare/${previous_version}...${version}"
113115
echo ""

hack/prepare-release.sh

Lines changed: 37 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -20,112 +20,59 @@ this=`basename $0`
2020

2121
usage () {
2222
cat << EOF
23-
Usage: $this [-h] [-a] RELEASE_VERSION
23+
Prepare for an NVIDIA Container Toolkit release
24+
25+
Usage: $this [-h] --previous-version <previous_version> --version <version>
2426
2527
Options:
26-
--previous-version specify the previous version (default: latest tag)
28+
--previous-version specify the previous version
29+
--version specify the version for this release.
2730
--help/-h show this help and exit
2831
2932
Example:
3033
31-
$this {{ VERSION }}
34+
$this --previous-version {{ PREVIOUS_VERSION}} --version {{ VERSION }}
3235
3336
EOF
3437
}
3538

36-
validate_semver() {
37-
local version=$1
38-
local semver_regex="^v([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$"
39-
40-
if [[ $version =~ $semver_regex ]]; then
41-
major=${BASH_REMATCH[1]}
42-
minor=${BASH_REMATCH[2]}
43-
patch=${BASH_REMATCH[3]}
44-
45-
# Check if major, minor, and patch are numeric
46-
if ! [[ $major =~ ^[0-9]+$ ]] || ! [[ $minor =~ ^[0-9]+$ ]] || ! [[ $patch =~ ^[0-9]+$ ]]; then
47-
echo "Invalid SemVer format: $version"
48-
return 1
49-
fi
50-
51-
# Validate prerelease if present
52-
if [[ ! -z "${BASH_REMATCH[5]}" ]]; then
53-
prerelease=${BASH_REMATCH[5]}
54-
prerelease_regex="^([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)$"
55-
if ! [[ $prerelease =~ $prerelease_regex ]]; then
56-
echo "Invalid SemVer format: $version"
57-
return 1
58-
fi
59-
fi
60-
61-
echo "Valid SemVer format: $version"
62-
return 0
63-
else
64-
echo "Invalid SemVer format: $version"
65-
return 1
66-
fi
67-
}
68-
69-
#
70-
# Parse command line
71-
#
72-
no_patching=
73-
previous_version=$(git describe --tags $(git rev-list --tags --max-count=1))
7439
# Parse command line options
40+
previous_version=
41+
version=
7542
while [[ $# -gt 0 ]]; do
7643
key="$1"
7744
case $key in
7845
--previous-version)
7946
previous_version="$2"
8047
shift 2
8148
;;
82-
--help/-h) usage
49+
--version)
50+
version="$2"
51+
shift 2
52+
;;
53+
--help/-h)
54+
usage
8355
exit 0
8456
;;
85-
*) break
57+
*) usage
58+
exit 1
8659
;;
8760
esac
8861
done
8962

9063
# Check that no extra args were provided
91-
if [ $# -ne 1 ]; then
92-
if [ $# -lt 1 ]; then
93-
echo -e "ERROR: too few arguments\n"
94-
else
95-
echo -e "ERROR: unknown arguments: ${@:3}\n"
96-
fi
64+
if [ -z "$version" ]; then
65+
echo -e "ERROR: --version is required"
9766
usage
9867
exit 1
9968
fi
10069

101-
release=$1
102-
shift 1
103-
104-
container_image=nvcr.io/nvidia/k8s-device-plugin:$release
105-
106-
#
107-
# Check/parse release number
108-
#
109-
if [ -z "$release" ]; then
110-
echo -e "ERROR: missing RELEASE_VERSION\n"
70+
if [ -z $previous_version ]; then
71+
echo -e "ERROR: --previous-version is required"
11172
usage
11273
exit 1
11374
fi
11475

115-
# validate the release version
116-
if ! validate_semver $release; then
117-
echo -e "ERROR: invalid RELEASE_VERSION\n"
118-
exit 1
119-
fi
120-
semver=${release:1}
121-
122-
# validate the previous version
123-
if ! validate_semver $previous_version; then
124-
echo -e "ERROR: invalid PREVIOUS_VERSION\n"
125-
exit 1
126-
fi
127-
pre_semver=${previous_version:1}
128-
12976
#
13077
# Modify files in the repo to point to new release
13178
#
@@ -137,10 +84,10 @@ else
13784
SED="sed"
13885
fi
13986

140-
# TODO: We need to ensure that this tooling also works on `release-*` branches.
14187
if [[ "$FORCE" != "yes" ]]; then
142-
if [[ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]]; then
143-
echo "Release scripts should be run on 'main'"
88+
current_head=$(git rev-parse --abbrev-ref HEAD)
89+
if [[ "${current_head}" != "main" || "${current_head}" != release-* ]]; then
90+
echo "Release scripts should be run on 'main' or on a 'release-*' branch"
14491
exit 1
14592
fi
14693
git fetch
@@ -155,39 +102,40 @@ fi
155102

156103
# Create a release issue.
157104
echo "Creating release tracking issue"
158-
cat RELEASE.md | sed "s/{{ .VERSION }}/$release/g" | \
105+
cat RELEASE.md | sed "s/{{ .VERSION }}/${version}/g" | \
159106
gh issue create -F - \
160-
-R NVIDIA/cloud-native-team \
161-
--title "Release nvidia-container-toolkit $release" \
162-
--label release
107+
-R NVIDIA/nvidia-container-toolkit \
108+
--title "Release nvidia-container-toolkit ${version}" \
109+
--label release \
110+
--milestone ${version}
163111

164-
echo "Creating a version bump branch: bump-release-${release}"
165-
git checkout -f -b bump-release-${release}
112+
echo "Creating a version bump branch: bump-release-${version}"
113+
git checkout -f -b bump-release-${version}
166114

167115
# Patch versions.mk
168116
LIB_VERSION=${release%-*}
169117
LIB_VERSION=${LIB_VERSION#v}
170118
if [[ ${release} == v*-rc.* ]]; then
171-
LIB_TAG_STRING=" ${release#*-}"
119+
LIB_TAG_STRING=" ${version#*-}"
172120
else
173121
LIB_TAG_STRING=
174122
fi
175123

176-
echo Patching versions.mk to refer to $release
124+
echo Patching versions.mk to refer to ${version}
177125
$SED -i "s/^LIB_VERSION.*$/LIB_VERSION := $LIB_VERSION/" versions.mk
178126
$SED -i "s/^LIB_TAG.*$/LIB_TAG :=$LIB_TAG_STRING/" versions.mk
179127

180128
git add versions.mk
181-
git commit -s -m "Bump version for $release release"
129+
git commit -s -m "Bump version for ${version} release"
182130

183-
if [[ $release != *-rc.* ]]; then
131+
if [[ ${version} != *-rc.* ]]; then
184132
# Patch README.md
185-
echo Patching README.md to refer to $release
186-
$SED -E -i -e "s/([^[:space:]])$previous_version([^[:alnum:]]|$)/\1$release\2/g" README.md
133+
echo Patching README.md to refer to ${version}
134+
$SED -E -i -e "s/([^[:space:]])$previous_version([^[:alnum:]]|$)/\1${version}\2/g" README.md
187135
$SED -E -i -e "s/$pre_semver/$semver/g" README.md
188136

189137
git add -u README.md
190-
git commit -s -m "Bump version to $release in README"
138+
git commit -s -m "Bump version to ${version} in README"
191139
else
192140
echo "Skipping README update for prerelease version"
193141
fi

0 commit comments

Comments
 (0)