Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e -o pipefail
- pomfile=pom.xml
- # fail if there is no ${pomfile}
- if [[ ! -e ${pomfile} ]]; then
- echo "Error: cannot edit ${pomfile}: No such file"
- exit 1
- fi
- # fail if "git checkout develop" didn't succeed
- echo "Calling git checkout develop"
- git checkout develop
- if [[ $? -ne 0 ]]; then
- exit 1
- fi
- VERSION=`grep -o -P "(?<=\<version\>).*(?=\</version\>)" ${pomfile} \
- | grep -o -P "[0-9][0-9\.]+[0-9]" | head -n 1`
- MINOR=`echo $VERSION | grep -o -P "[0-9]+$"`
- MAJOR=`echo $VERSION | grep -o -P "([0-9]+\.)*[0-9]+(?=\.$MINOR)"`
- NVERSION=$MAJOR.$(( MINOR+1 ))
- echo "Current version ${VERSION} bumped to new version ${NVERSION}"
- git flow release start $VERSION
- git flow release finish -m $VERSION $VERSION
- git checkout develop
- # change only the first occasion of pattern
- sed "0,/<version>${VERSION}/s//<version>${NVERSION}/" --in-place ${pomfile}
- git add pom.xml
- git commit -m "version bump"
Advertisement
Add Comment
Please, Sign In to add comment