|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# https://github.com/lightblue-platform/lightblue-docs-developer/issues/6 |
| 4 | + |
| 5 | +RELEASE_VERSION=$1 |
| 6 | +DEVEL_VERSION=$2 |
| 7 | + |
| 8 | +if [ $1"x" == "x" ] || [ $2"x" == "x" ]; then |
| 9 | + echo "Usage: ./release.sh <release version> <new snapshot version>" |
| 10 | + echo "Example: ./release 1.1.0 1.2.0-SNAPSHOT" |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +# prepare and verify state |
| 15 | +git fetch --all |
| 16 | +rm -rf ~/.m2/repository/com/redhat/lightblue/ |
| 17 | + |
| 18 | +BRANCH=`git branch | grep ^* | awk '{print $2}'` |
| 19 | + |
| 20 | +if [ $BRANCH != "master" ]; then |
| 21 | + read -p "Current branch is '${BRANCH}', not 'master'. Do you wish to continue? (y/N) " |
| 22 | + if [ "$REPLY" != "y"]; then |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | +fi |
| 26 | + |
| 27 | +# check that local branch is equal to upstream master (assumes remote of origin) |
| 28 | +MERGE_BASE=`git merge-base HEAD origin/master` |
| 29 | +HEAD_HASH=`git rev-parse HEAD` |
| 30 | + |
| 31 | +if [ $MERGE_BASE != $HEAD_HASH ]; then |
| 32 | + echo "Local branch is not in sync with origin/master. Fix and run this script again." |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | + |
| 36 | +# update to non-snapshot versions of lightblue dependencies and commit |
| 37 | +mvn versions:update-properties -DallowSnapshots=false |
| 38 | +git commit -a -m "Updated versions to non snapshot" |
| 39 | + |
| 40 | +# prepare for release (note, this will warn if any snapshot dependencies still exist and allow for fixing) |
| 41 | +mvn release:prepare -P release \ |
| 42 | + -DpushChanges=false \ |
| 43 | + -DreleaseVersion=$RELEASE_VERSION \ |
| 44 | + -DdevelopmentVersion=$DEVEL_VERSION \ |
| 45 | + -Dtag=V${RELEASE_VERSION} || exit |
| 46 | + |
| 47 | +# push prepared changes (doing separate just to have control) |
| 48 | +git push origin master --tags |
| 49 | + |
| 50 | +# perform release |
| 51 | +mvn release:perform -P release || exit |
| 52 | + |
| 53 | +mvn clean deploy |
0 commit comments