1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/bin/bash -e
#
# Attempt to bump the appc release to the specified version by replacing all
# occurrences of the current/previous version.
#
# Generates two commits: the release itself and the bump to the next +git
# version
#
# YMMV, no disclaimer or warranty, etc.
if ! [[ "$1" =~ ^v[[:digit:]]+.[[:digit:]]+.[[:digit:]]$ ]]; then
echo "Usage: scripts/bump-release <VERSION>"
echo " where VERSION must be vX.Y.Z"
exit 255
fi
function replace_all() {
REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $1)
git ls-files | fgrep -v CHANGELOG.md | xargs sed -i -e "s/$REPLACE/$2/g"
}
function replace_version() {
REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $1)
sed -i -e "s/$REPLACE/$2/g" VERSION schema/version.go
}
NEXT=${1:1} # 0.2.3
NEXTGIT="${NEXT}+git" # 0.2.3+git
PREVGIT=$(cat VERSION) # 0.1.2+git
PREV=${PREVGIT::-4} # 0.1.2
replace_version $PREVGIT $NEXT
replace_all $PREV $NEXT
git commit -am "version: bump to v${NEXT}"
replace_version $NEXT $NEXTGIT
git commit -am "version: bump to v${NEXTGIT}"
|