[Project] cleanup in autoRelease.sh and release.sh

This commit is contained in:
Robert von Burg 2017-10-03 11:58:20 +02:00
parent 91c231cdd7
commit 33105cdf14
2 changed files with 23 additions and 27 deletions

View File

@ -80,7 +80,7 @@ if ! git checkout -b temp ; then
exit 1
fi
# set hotfix version
# set release version
echo -e "\nINFO: Setting version..."
if ! mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${newVersion} > /dev/null ; then
echo -e "ERROR: Failed to set new version!"
@ -117,7 +117,7 @@ if ! mvn source:jar install -DskipTests > /dev/null ; then
fi
# git push
echo -e "\nINFO: Hotfix ${newVersion} created. Do you want to push to origin? y/n"
echo -e "\nINFO: Release ${newVersion} created. Do you want to push to origin? y/n"
read a
if [[ "${a}" == "y" || "${a}" == "Y" ]] ; then
echo -e "INFO: Pushing to origin..."
@ -125,11 +125,10 @@ if [[ "${a}" == "y" || "${a}" == "Y" ]] ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed hotfix tag ${newVersion}"
echo -e "\nINFO: Pushed release tag ${newVersion}"
else
echo -e "WARN: Release not pushed!"
fi
echo -e "\nINFO: Hotfix ${newVersion} created."
echo -e "\nINFO: Release ${newVersion} created."
exit 0

View File

@ -2,42 +2,39 @@
# usage
if [ $# != 2 ] ; then
echo -e "Usage: ${0} <release_branch> <hotfix_version>"
echo -e "Usage: ${0} <release_branch> <release_version>"
exit 1
fi
# cleanup trap
function cleanup {
echo -e "\nINFO: Cleaning up..."
git checkout ${releaseBranch}
git checkout .
git branch -D temp
}
trap cleanup EXIT
# Confirm
releaseBranch="${1}"
hotfixVersion="${2}"
echo -e "INFO: Do you want to make hotfix version ${hotfixVersion} from release branch ${releaseBranch}? y/n"
newVersion="${2}"
echo -e "INFO: Do you want to make release version ${newVersion} from release branch ${releaseBranch}? y/n"
read a
if [[ "${a}" != "y" && "${a}" != "Y" ]] ; then
exit 0;
fi
# validate tag does not exist
echo -e "INFO: Fetching tags and branches and validating they do not exist..."
if ! git fetch --all --tags > /dev/null ; then
echo -e "ERROR: Tags and branches could not be fetched!"
exit 1
fi
if git tag | grep ${hotfixVersion} > /dev/null ; then
if git tag | grep ${newVersion} > /dev/null ; then
echo -e "ERROR: Tag already exists!"
exit 1
fi
# make sure gpg-agent is available and loaded
echo -e "\nINFO: Searching for gpg-agent..."
if ! which gpg-agent ; then
@ -55,7 +52,6 @@ if ! gpg-agent 2>&1 | grep "running and available" ; then
fi
fi
# Checkout release branch
echo -e "\nINFO: Checking out release branch ${releaseBranch}"
if ! git checkout ${releaseBranch} ; then
@ -63,7 +59,6 @@ if ! git checkout ${releaseBranch} ; then
exit 1
fi
# create temp branch
echo -e "\nINFO: Creating temp branch..."
if ! git checkout -b temp ; then
@ -71,15 +66,13 @@ if ! git checkout -b temp ; then
exit 1
fi
# set hotfix version
# set release version
echo -e "\nINFO: Setting version..."
if ! mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${hotfixVersion} > /dev/null ; then
if ! mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${newVersion} > /dev/null ; then
echo -e "ERROR: Failed to set new version!"
exit 1
fi
# build
echo -e "\nINFO: Doing a build with new version..."
if ! mvn clean package -DskipTests > /dev/null ; then
@ -87,37 +80,41 @@ if ! mvn clean package -DskipTests > /dev/null ; then
exit 1
fi
# commit to tag
echo -e "\nINFO: Creating tag..."
if ! git add . ; then
echo -e "ERROR: Failed to git add"
exit 1
fi
if ! git commit -m "[Project] Set new version ${hotfixVersion}" ; then
if ! git commit -m "[Project] Set new version ${newVersion}" ; then
echo -e "ERROR: Failed to git commit"
exit 1
fi
if ! git tag --sign --message "[Project] New Version ${hotfixVersion}" ${hotfixVersion} ; then
if ! git tag --sign --message "[Project] New Version ${newVersion}" ${newVersion} ; then
echo -e "ERROR: Failed to git tag"
exit 1
fi
# local install
echo -e "\nINFO: Installing new version..."
if ! mvn source:jar install -DskipTests > /dev/null ; then
echo -e "ERROR: Failed to install new version!"
exit 1
fi
# git push
echo -e "\nINFO: Hotfix ${hotfixVersion} created. Do you want to push to origin? y/n"
echo -e "\nINFO: Release ${newVersion} created. Do you want to push to origin? y/n"
read a
if [[ "${a}" == "y" || "${a}" == "Y" ]] ; then
echo -e "INFO: Pushing to origin..."
if ! git push origin ${hotfixVersion} ; then
if ! git push origin ${newVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed hotfix tag ${hotfixVersion}"
echo -e "\nINFO: Pushed release tag ${newVersion}"
else
echo -e "WARN: Release not pushed!"
fi
echo -e "\nINFO: Hotfix ${hotfixVersion} created."
echo -e "\nINFO: Release ${newVersion} created."
exit 0