Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make update_changelog.sh use the latest version tag by default #585

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions scripts/update_changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,51 @@


ORIGINAL_OPTS=$*
OPTS=$(getopt -l "help,since-tag:,latest-tag,token:" -o "hlt" -- "$@") || exit 1
OPTS=$(getopt -l "help,since-tag:,full,token:" -o "hft" -- "$@") || exit 1

eval set -- "$OPTS"
while true
do
case $1 in
-h|--help)
echo -e "Usage: $0 [-h|--help] [--since-tag <tag>] [-l|--latest-tag] [-t|--token <token>]
echo -e "Usage: $0 [-h|--help] [-f|--full] [--since-tag <tag>] [-t|--token <token>]
-h, --help Display help
--since-tag <tag> Process changes since tag <tag>
-l, --latest-tag Process changes since latest tag
-f, --full Process changes since the beginning (by default: since latest git version tag)
--since-tag <tag> Process changes since git version tag <tag> (by default: since latest git version tag)
--token <token> Pass changelog github token <token>"
exit 0
;;
--since-tag)
--since-tag)
shift
TAG="$1"
;;
-l|--latest-tag)
TAG=$(git tag --sort=creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | tail -1)
ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b/--since-tag $TAG/")
-f|--full)
TAG="<FULL>"
ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b//")
;;
--)
--)
shift
break
;;
esac
shift
done


if [ -z "$TAG" ]
then
# Use latest git version tag
TAG=$(git tag --sort=creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | tail -1)
ORIGINAL_OPTS="$ORIGINAL_OPTS --since-tag $TAG"
fi

echo "Git version tag: $TAG"

cp CHANGELOG.md /tmp/CHANGELOG.md.$$
sed -i -n "/^## \\[$TAG\\]/,\$p" CHANGELOG.md
# Consolidate tag for matching changelog entries
TAG=$(echo "$TAG" | sed 's/-\([A-Za-z]*\)[^A-Za-z]*/-\1/')
echo "Consolidated tag: $TAG"
sed -i -n "/^## \\[${TAG}[^]]*\\]/,\$p" CHANGELOG.md

github_changelog_generator -u CosmWasm -p cw-plus --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md

Expand Down