github.com/coreos/rocket@v1.30.1-0.20200224141603-171c416fac02/scripts/bump-release (about) 1 #!/bin/bash -e 2 # 3 # Attempt to bump the rkt release to the specified version by replacing all 4 # occurrences of the current/previous version. 5 # 6 # Generates two commits: the release itself and the bump to the next +git 7 # version 8 # 9 # YMMV, no disclaimer or warranty, etc. 10 11 # make sure we are running in a toplevel directory 12 if ! [[ "$0" =~ "scripts/bump-release" ]]; then 13 echo "This script must be run in a toplevel rkt directory" 14 exit 255 15 fi 16 17 if ! [[ "$1" =~ ^v[[:digit:]]+.[[:digit:]]+.[[:digit:]]$ ]]; then 18 echo "Usage: scripts/bump-release <VERSION>" 19 echo " where VERSION must be vX.Y.Z" 20 exit 255 21 fi 22 23 function replace_stuff() { 24 local FROM 25 local TO 26 local REPLACE 27 28 FROM=$1 29 TO=$2 30 # escape special characters 31 REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $FROM) 32 shift 2 33 echo $* | xargs sed -i --follow-symlinks -e "s/$REPLACE/$TO/g" 34 } 35 36 function replace_all() { 37 replace_stuff $1 $2 $(git ls-files | grep -Ev "(CHANGELOG.md|vendor|manifest\.d|glide.lock|glide.yaml)") 38 } 39 40 function replace_version() { 41 replace_stuff $1 $2 configure.ac scripts/build-rir.sh tests/rkt-monitor/build-stresser.sh 42 } 43 44 NEXT=${1:1} # 0.2.3 45 NEXTGIT="${NEXT}+git" # 0.2.3+git 46 47 PREVGIT=$(grep -Po 'AC_INIT\(\[rkt\], \[\K[^\]]*(?=])' configure.ac) # 0.1.2+git 48 PREV=${PREVGIT::-4} # 0.1.2 49 50 replace_version $PREVGIT $NEXT 51 replace_all $PREV $NEXT 52 git commit -am "version: bump to v${NEXT}" 53 54 replace_version $NEXT $NEXTGIT 55 git commit -am "version: bump to v${NEXTGIT}"