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:]')
|
|
|
|
|
|
|
|
VERSION="v${LIB_VERSION}${LIB_TAG+-${LIB_TAG}}"
|
|
|
|
>&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
|
|
|
|
|
|
|
# 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 09:40:47 +00:00
|
|
|
echo "# Changelog"
|
2024-06-17 13:33:11 +00:00
|
|
|
echo ""
|
2024-07-10 09:40:47 +00:00
|
|
|
echo "## $VERSION"
|
2024-06-17 13:33:11 +00:00
|
|
|
|
|
|
|
# Iterate over the commit messages and ignore the ones that start with "Merge" or "Bump"
|
2024-06-24 11:02:53 +00:00
|
|
|
git log --pretty=format:"%s" $REFERENCE..@ | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
|