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