Files
rkt/scripts/bump-release
2015-04-24 14:11:30 -07:00

39 lines
1.0 KiB
Bash
Executable File

#!/bin/bash -e
#
# Attempt to bump the rkt 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 | 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/version.go
}
NEXT=${1:1} # 0.2.3
NEXTGIT="${NEXT}+git" # 0.2.3+git
PREVGIT=$(awk -F '"' '/const Version/ { print $2 }' version/version.go) # 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}"