github.com/blixtra/rkt@v0.8.1-0.20160204105720-ab0d1add1a43/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_all() {
    24  	REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $1)
    25  	git ls-files | grep -Ev "(CHANGELOG.md|Godeps)" | xargs sed -i --follow-symlinks -e "s/$REPLACE/$2/g"
    26  }
    27  
    28  function replace_version() {
    29  	REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $1)
    30  	sed -i -e "s/$REPLACE/$2/g" configure.ac
    31  }
    32  
    33  NEXT=${1:1} 	        # 0.2.3
    34  NEXTGIT="${NEXT}+git"   # 0.2.3+git
    35  
    36  PREVGIT=$(grep -Po 'AC_INIT\(\[rkt\], \[\K[^\]]*(?=])' configure.ac) # 0.1.2+git
    37  PREV=${PREVGIT::-4}     # 0.1.2
    38  
    39  replace_version $PREVGIT $NEXT
    40  replace_all $PREV $NEXT
    41  git commit -am "version: bump to v${NEXT}"
    42  
    43  replace_version $NEXT $NEXTGIT
    44  git commit -am "version: bump to v${NEXTGIT}"