Make update-version script more usable.

- Fail if uncommited or staged changes are in the working directory.
- Show the version changes as a diff.
- On success show the commit log message.
This commit is contained in:
Andrew Hamilton 2021-12-22 17:49:31 +10:00
parent 292f58e309
commit b522577fa3

View file

@ -4,9 +4,12 @@
set -e
# Script only runs at the codebase root.
# Only run at the codebase root.
[ $(basename $PWD) == "eris" ]
[ -e README.md ]
# Don't run with uncommited or staged changes.
git diff --exit-code
git diff --cached --exit-code
NEW_VERSION=$(date "+v%Y.%m.%d")
@ -15,6 +18,8 @@ if [ $NEW_VERSION == $CURRENT_VERSION ]; then
git tag --delete $CURRENT_VERSION
else
git grep -l $CURRENT_VERSION | xargs sed -i "s/$CURRENT_VERSION/$NEW_VERSION/g"
git diff
git commit --all --message="Update version from $CURRENT_VERSION to $NEW_VERSION."
fi
git tag $NEW_VERSION
git log --max-count=1