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

Update changelog 2 #428

Merged
merged 10 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ To generate a changelog we decided to use [github-changelog-generator](https://g

To install tool you need Ruby's `gem` package manager.

$ gem install github_changelog_generator
$ gem --user install github_changelog_generator

And put `$HOME/.gem/ruby/*/bin/` into your PATH.

Generating changelog file first time:

Expand All @@ -218,7 +220,12 @@ Appending next releases could be done adding `--base` flag:

$ github_changelog_generator -u CosmWasm -p cw-plus --base CHANGELOG.md

If you hit GitHub's 50 requests/hour limit, please follow [this](https://github.com/github-changelog-generator/github-changelog-generator#github-token) guide to create a token key which you can pass using `--token` flag.
If you hit GitHub's 50 requests/hour limit, please follow [this](https://github.com/github-changelog-generator/github-changelog-generator#github-token)
guide to create a token key which you can pass using `--token` flag.

There's also a convenience `scripts/update_changelog.sh`, which can take a
--since-tag parameter (to avoid processing the entire history). It can also
auto-detect the latest version tag for you, with --latest-tag.

## Licenses

Expand Down
39 changes: 38 additions & 1 deletion scripts/update_changelog.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
#!/bin/bash

github_changelog_generator -u CosmWasm -p cw-plus --base CHANGELOG.md

ORIGINAL_OPTS=$*
OPTS=$(getopt -l "help,since-tag:,latest-tag,token:" -o "hlt" -- "$@") || 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>]
-h, --help Display help
--since-tag <tag> Process changes since tag <tag>
-l, --latest-tag Process changes since latest tag
--token <token> Pass changelog github token <token>"
exit 0
;;
--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/")
;;
--)
shift
break
;;
esac
shift
done

cp CHANGELOG.md /tmp/CHANGELOG.md.$$
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

rm -f /tmp/CHANGELOG.md.$$