[Project] release scripts auto push

This commit is contained in:
Robert von Burg 2017-10-13 11:33:35 +02:00
parent 1e79ea43de
commit 081c0dc866
3 changed files with 35 additions and 67 deletions

View File

@ -117,18 +117,11 @@ if ! mvn source:jar install -DskipTests > /dev/null ; then
fi
# git push
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 ${newVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed release tag ${newVersion}"
else
echo -e "WARN: Release not pushed!"
if ! git push origin ${newVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed release tag ${newVersion}"
echo -e "\nINFO: Release ${newVersion} created."
exit 0

View File

@ -6,6 +6,9 @@ if [ $# != 2 ] ; then
exit 1
fi
releaseBranch="${1}"
newVersion="${2}"
# cleanup trap
function cleanup {
echo -e "\nINFO: Cleaning up..."
@ -16,8 +19,6 @@ function cleanup {
trap cleanup EXIT
# Confirm
releaseBranch="${1}"
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
@ -103,18 +104,11 @@ if ! mvn source:jar install -DskipTests > /dev/null ; then
fi
# git push
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 ${newVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed release tag ${newVersion}"
else
echo -e "WARN: Release not pushed!"
if ! git push origin ${newVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed release tag ${newVersion}"
echo -e "\nINFO: Release ${newVersion} created."
exit 0

View File

@ -6,17 +6,25 @@ if [ $# != 2 ] ; then
exit 1
fi
# Confirm
sourceBranch=${1}
releaseVersion=${2}
# cleanup trap
function cleanup {
echo -e "\nINFO: Cleaning up..."
git checkout ${sourceBranch}
git checkout .
git branch -D temp
}
trap cleanup EXIT
# Confirm
echo -e "INFO: Do you want to release version ${releaseVersion} from branch ${sourceBranch}? y/n"
read a
if [[ "${a}" != "y" && "${a}" != "Y" ]] ; then
exit 0;
fi
# validate tag and release branch do not exist
echo -e "INFO: Fetching tags and branches and validating they do not exist..."
if ! git fetch --all --tags > /dev/null ; then
@ -32,13 +40,6 @@ if git branch --all | grep "release/${releaseVersion}" > /dev/null ; then
exit 1
fi
# validate tag does not exist
if git tag | grep "${releaseVersion}" > /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
@ -56,7 +57,6 @@ if ! gpg-agent 2>&1 | grep "running and available" ; then
fi
fi
# Checkout source branch
echo -e "\nINFO: Checking out source branch ${sourceBranch}"
if ! git checkout ${sourceBranch} ; then
@ -64,7 +64,6 @@ if ! git checkout ${sourceBranch} ; then
exit 1
fi
# create new release branch, and temp tag
echo -e "\nINFO: Creating release and temp branches..."
if ! git checkout -b release/${releaseVersion} ; then
@ -76,7 +75,6 @@ if ! git checkout -b temp ; then
exit 1
fi
# set release version
echo -e "\nINFO: Setting version..."
if ! mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${releaseVersion} > /dev/null ; then
@ -84,7 +82,6 @@ if ! mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${releaseVersion}
exit 1
fi
# build
echo -e "\nINFO: Doing a build with new version..."
if ! mvn clean package -DskipTests > /dev/null ; then
@ -92,7 +89,6 @@ if ! mvn clean package -DskipTests > /dev/null ; then
exit 1
fi
# commit to tag
echo -e "\nINFO: Creating tag..."
if ! git add . ; then
@ -108,40 +104,25 @@ if ! git tag --sign --message "[Project] New Version ${releaseVersion}" ${releas
exit 1
fi
# cleanup
echo -e "\nINFO: Cleaning up..."
if ! git checkout release/${releaseVersion} ; then
echo -e "ERROR: Failed to checkout release branch"
# 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
if ! git branch -D temp ; then
echo -e "ERROR: Failed to delete temp branch"
exit 1
fi
# git push
echo -e "\nINFO: Release ${releaseVersion} 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 release/${releaseVersion} ; then
echo -e "ERROR: Failed to push release branch"
exit 1
fi
if ! git push origin ${releaseVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed release branch and tag for release version ${releaseVersion}"
else
echo -e "WARN: Release not pushed!"
echo -e "INFO: Pushing to origin..."
if ! git push origin release/${releaseVersion} ; then
echo -e "ERROR: Failed to push release branch"
exit 1
fi
if ! git push origin ${releaseVersion} ; then
echo -e "ERROR: Failed to push tag"
exit 1
fi
echo -e "\nINFO: Pushed release branch and tag for release version ${releaseVersion}"
echo -e "\nINFO: Release ${releaseVersion} created."
echo -e "INFO: Don't forget to update snapshot version!"
exit 0