[Project] creating release script

This commit is contained in:
Robert von Burg 2014-09-20 12:27:20 +02:00
parent 434487235a
commit 15f4dab2f5
6 changed files with 157 additions and 5 deletions

@ -1 +1 @@
Subproject commit dc3beef5bfb45608217914e4bc1a45e2935f3dd3
Subproject commit 8498efc8fe502250ea089cd71c5523b2477c8d56

@ -1 +1 @@
Subproject commit a70b4309860cd3da8f22b20b4589973c115bb238
Subproject commit c8816472fcd89225178b66fad782ad49f83f181d

@ -1 +1 @@
Subproject commit 54092c87d4a5e3eaf0c4cae894367cfafaecad15
Subproject commit afcb7c41fc57548f76857a4dd2b868ca0d5b042b

@ -1 +1 @@
Subproject commit cf1a6135350c6097aad14bfc98a93fdfe5f4d697
Subproject commit c3fe4bdec64d1eb56c28f9df0e19a7c7bbc570c7

148
release.sh Executable file
View File

@ -0,0 +1,148 @@
#!/bin/bash
function usage() {
echo "Usage: $0 [-c] [-r <release_branch>] [-b <branch>] [-o <old_version>] [-n <new_version>]" 1>&2;
exit 1;
}
while getopts ":b:o:n:r:c" arg; do
case "${arg}" in
c)
c="true"
;;
r)
r=${OPTARG}
;;
b)
b=${OPTARG}
;;
o)
o=${OPTARG}
;;
n)
n=${OPTARG}
;;
*)
echo "ERROR: Unknown arg ${arg}"
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${r}" ] || [ -z "${b}" ] || [ -z "${o}" ] || [ -z "${n}" ] ; then
echo "ERROR: Missing an argument!"
usage
fi
#if [ "$(git status --short)" != "" ] ; then
# echo "You have uncommitted changes!"
# exit 1
#fi
create_release_branch="${c}"
release_branch="${r}"
branch="${b}"
old_version="${o}"
new_version="${n}"
root="${PWD}"
echo "old_version=${old_version}"
echo "new_version=${new_version}"
echo "branch=${branch}"
echo "release_branch=${release_branch}"
if [ -n "${create_release_branch}" ] ; then
echo "Creating release branch."
else
echo "NOT creating release branch."
fi
exit
function fail() {
git submodule foreach git reset --hard origin/${branch}
git submodule foreach git checkout ${branch}
if [ -n "${create_release_branch}" ] ; then
git submodule foreach git branch -d ${release_branch}
fi
git submodule foreach git tag -d ${new_version}
git checkout ${branch}
git reset --hard origin/${branch}
git branch -d ${release_branch}
git tag -d ${new_version}
echo -e "\nERROR: Failed to release version ${new_version}"
exit 1
}
# create release branch
if [ -n "${create_release_branch}" ] ; then
if ! git branch ${release_branch} ${branch} ; then
fail
fi
if ! git submodule foreach git branch ${release_branch} ${branch} ; then
fail
fi
fi
# checkout release branch
if ! git checkout ${release_branch} ; then
fail
fi
if ! git submodule foreach git checkout ${release_branch} ; then
fail
fi
# bump version
if ! ./setVersion.sh ${old_version} ${new_version} ; then
fail
fi
# show status
if ! git status --short ; then
fail
fi
if ! git submodule foreach git status --short ; then
fail
fi
echo "Do you want to carry on?"
read
if ! git submodule foreach git add . ; then
fail
fi
if ! git submodule foreach git commit -m "[Project] bumped version from ${old_version} to ${new_version}" ; then
fail
fi
if ! git submodule foreach git tag ${new_version} ; then
fail
fi
if ! git submodule sync ; then
fail
fi
if ! git add . ; then
fail
fi
if ! git commit -m "[Project] bumped version from ${old_version} to ${new_version}" ; then
fail
fi
if ! git tag ${new_version} ; then
fail
fi
git submodule foreach git checkout ${branch}
if [ -n "${create_release_branch}" ] ; then
git submodule foreach git branch -d ${release_branch}
fi
git checkout ${branch}
if [ -n "${create_release_branch}" ] ; then
git branch -d ${release_branch}
fi
echo -e "\nINFO: Released version ${new_version}"
exit 0

View File

@ -20,7 +20,7 @@ new_version="$2"
root="${PWD}"
function fail() {
echo "ERROR: Failed to set version of $1"
echo -e "\nERROR: Failed to set version of $1"
exit 1
}
@ -78,3 +78,7 @@ cd "${root}"
if ! sed --in-place "s/${old_version}/${new_version}/" li.strolch.dev/createBundle.sh 2>/dev/null ; then
fail "${root}/li.strolch.dev/createBundle.sh"
fi
echo -e "\nINFO: Bumped version from ${old_version} to ${new_version}"
exit 0