2024-06-17 13:33:11 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
this=`basename $0`
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
cat << EOF
|
|
|
|
Generate a changelog for the specified tag
|
|
|
|
Usage: $this --reference <tag> [--remote <remote_name>]
|
|
|
|
|
|
|
|
Options:
|
|
|
|
--since specify the tag to start the changelog from (default: latest tag)
|
|
|
|
--version specify the version to be released
|
|
|
|
--help/-h show this help and exit
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2024-07-10 09:40:47 +00:00
|
|
|
LIB_VERSION=$(awk -F= '/^LIB_VERSION/ { print $2 }' versions.mk | tr -d '[:space:]')
|
|
|
|
LIB_TAG=$(awk -F= '/^LIB_TAG/ { print $2 }' versions.mk | tr -d '[:space:]')
|
|
|
|
|
2024-07-15 12:47:54 +00:00
|
|
|
VERSION="v${LIB_VERSION}${LIB_TAG:+-${LIB_TAG}}"
|
2024-07-10 09:40:47 +00:00
|
|
|
>&2 echo "VERSION=$VERSION"
|
|
|
|
|
2024-06-17 13:33:11 +00:00
|
|
|
REFERENCE=
|
|
|
|
|
|
|
|
# Parse command line options
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
key="$1"
|
|
|
|
case $key in
|
|
|
|
--since)
|
|
|
|
REFERENCE="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
|
|
|
;;
|
|
|
|
--version)
|
|
|
|
VERSION="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
|
|
|
;;
|
|
|
|
--help/-h) usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*) usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Fetch the latest tags from the remote
|
2024-06-17 13:33:11 +00:00
|
|
|
remote=$( git remote -v | grep -E "NVIDIA/nvidia-container-toolkit(\.git)?\s" | grep -oE "^[a-z]+" | sort -u )
|
|
|
|
>&2 echo "Detected remote as '${remote}'"
|
|
|
|
git fetch ${remote} --tags
|
2024-06-17 13:33:11 +00:00
|
|
|
|
2024-07-10 13:51:09 +00:00
|
|
|
git tag | grep ${VERSION} > /dev/null
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
>&2 echo "${VERSION} is not a valid git reference, using HEAD"
|
|
|
|
VERSION=HEAD
|
|
|
|
fi
|
|
|
|
|
2024-06-17 13:33:11 +00:00
|
|
|
# if REFERENCE is not set, get the latest tag
|
|
|
|
if [ -z "$REFERENCE" ]; then
|
2024-06-17 13:33:11 +00:00
|
|
|
most_recent_tag=$(git tag --sort=-creatordate | head -1)
|
|
|
|
if [ "${VERSION}" == "${most_recent_tag}" ]; then
|
|
|
|
REFERENCE=$(git tag --sort=-creatordate | head -2 | tail -1)
|
|
|
|
else
|
|
|
|
REFERENCE=${most_recent_tag}
|
|
|
|
fi
|
2024-06-17 13:33:11 +00:00
|
|
|
fi
|
|
|
|
|
2024-06-17 13:33:11 +00:00
|
|
|
>&2 echo "Using ${REFERENCE} as previous version"
|
|
|
|
|
2024-06-17 13:33:11 +00:00
|
|
|
# Print the changelog
|
2024-07-10 13:51:09 +00:00
|
|
|
echo "## What's Changed"
|
2024-06-17 13:33:11 +00:00
|
|
|
echo ""
|
|
|
|
# Iterate over the commit messages and ignore the ones that start with "Merge" or "Bump"
|
2024-07-10 13:51:09 +00:00
|
|
|
git log --pretty=format:"%s" $REFERENCE..$VERSION -- ':!deployments/container' ':!tools' | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "### Changes in the Toolkit Container"
|
|
|
|
echo ""
|
|
|
|
git log --pretty=format:"%s" $REFERENCE..$VERSION -- deployments/container tools | grep -Ev "(^Merge )|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
|
|
|
|
|
|
|
|
LIB_NVIDIA_CONTAINER_REFERENCE=$( git ls-tree $REFERENCE third_party/libnvidia-container --object-only )
|
|
|
|
LIB_NVIDIA_CONTAINER_VERSION=$( git ls-tree $VERSION third_party/libnvidia-container --object-only )
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
if [[ $(git -C third_party/libnvidia-container log --pretty=format:"%s" $LIB_NVIDIA_CONTAINER_REFERENCE..$LIB_NVIDIA_CONTAINER_VERSION | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g' | wc -l) -gt 0 ]]; then
|
|
|
|
echo "### Changes in libnvidia-container"
|
|
|
|
echo ""
|
|
|
|
git -C third_party/libnvidia-container log --pretty=format:"%s" $LIB_NVIDIA_CONTAINER_REFERENCE..$LIB_NVIDIA_CONTAINER_VERSION | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "**Full Changelog**: https://github.com/NVIDIA/nvidia-container-toolkit/compare/${REFERENCE}...${VERSION}"
|
|
|
|
echo ""
|