2010-09-12 18:47:21 -04:00
|
|
|
#! /bin/sh
|
|
|
|
|
2010-10-12 07:56:06 -04:00
|
|
|
################################################################################
|
|
|
|
# tagRelease.sh
|
|
|
|
#
|
|
|
|
# Replacement for the maven-release-plugin
|
|
|
|
################################################################################
|
2010-10-12 08:18:49 -04:00
|
|
|
# be defensive and stop the script
|
|
|
|
set -o nounset # when there are uninitalised variables
|
|
|
|
set -o errexit # or when statements return non true values
|
2010-10-12 07:43:11 -04:00
|
|
|
|
2010-09-12 18:47:21 -04:00
|
|
|
usage="Usage: tagRelease [-u] [-e exportDirectory] [-r releaseVersion] [-d devVersion]"
|
|
|
|
projectDir=`pwd`
|
|
|
|
|
|
|
|
releaseVersion=
|
|
|
|
devVersion=
|
|
|
|
|
|
|
|
performUpdate=''
|
|
|
|
exportDirectory=''
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Update all project poms and commit the changes.
|
|
|
|
#
|
|
|
|
# $1: project directory (base directory of recursve find)
|
|
|
|
# $2: new value for the pom version
|
2010-10-12 07:43:11 -04:00
|
|
|
################################################################################
|
2010-09-12 18:47:21 -04:00
|
|
|
updatePomVersionsAndCommit() {
|
|
|
|
for i in `find $1 -name "pom.xml"`; do
|
|
|
|
xmlstarlet ed -P -N x="http://maven.apache.org/POM/4.0.0" \
|
|
|
|
-u "/x:project/x:parent/x:version" -v $2 \
|
|
|
|
-u "/x:project/x:version" -v $2 \
|
|
|
|
$i > tmp
|
|
|
|
mv tmp $i
|
|
|
|
done
|
2010-10-12 08:18:49 -04:00
|
|
|
git commit -a -m "Updating pom versions to $2"
|
2010-09-12 18:47:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Start script processing
|
|
|
|
################################################################################
|
|
|
|
while getopts ":e:r:d:u" opt; do
|
|
|
|
case $opt in
|
|
|
|
r)
|
|
|
|
releaseVersion=$OPTARG;;
|
|
|
|
d)
|
|
|
|
devVersion=$OPTARG;;
|
|
|
|
u)
|
|
|
|
performUpdate="true";;
|
|
|
|
e)
|
|
|
|
exportDirectory=$OPTARG;;
|
|
|
|
h)
|
|
|
|
echo $usage;;
|
|
|
|
\?)
|
|
|
|
echo $usage
|
|
|
|
exit 1;;
|
|
|
|
*)
|
|
|
|
echo $usage
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z $releaseVersion ]; then
|
|
|
|
read -p "Enter the release version: " releaseVersion
|
|
|
|
fi
|
|
|
|
if [ -z $devVersion ]; then
|
|
|
|
read -p "Enter the development version: " devVersion
|
|
|
|
fi
|
|
|
|
|
|
|
|
projectName=`xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -v "/x:project/x:artifactId" pom.xml`
|
2010-09-30 04:49:21 -04:00
|
|
|
if [ -z "$projectName" ]; then
|
2010-09-12 18:47:21 -04:00
|
|
|
echo "Could not determine propject name (misasing/incomplete pom?)."
|
|
|
|
exit;
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Confirm data
|
|
|
|
|
|
|
|
echo "About to tag release with following information:"
|
|
|
|
echo " tag version : $releaseVersion"
|
|
|
|
echo " dev version : $devVersion"
|
|
|
|
while true; do
|
|
|
|
read -p "Continue? " yn
|
|
|
|
case $yn in
|
|
|
|
[Yy]* ) break;;
|
|
|
|
[Nn]* ) exit;;
|
|
|
|
* ) echo "Please answer yes or no.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Go, go , go
|
|
|
|
|
|
|
|
if [ -n "$performUpdate" ]; then
|
2010-10-12 07:43:11 -04:00
|
|
|
echo "Performing requested git pull..."
|
|
|
|
git pull
|
2010-09-12 18:47:21 -04:00
|
|
|
fi
|
|
|
|
|
2010-10-12 07:43:11 -04:00
|
|
|
updatePomVersionsAndCommit $projectDir $releaseVersion
|
2010-09-12 18:47:21 -04:00
|
|
|
|
2010-10-12 07:43:11 -04:00
|
|
|
git tag -m "Tagging $releaseVersion release" $releaseVersion
|
2010-09-12 18:47:21 -04:00
|
|
|
|
2010-10-12 07:43:11 -04:00
|
|
|
updatePomVersionsAndCommit $projectDir $devVersion
|
2010-09-12 18:47:21 -04:00
|
|
|
|
|
|
|
if [ $exportDirectory ]; then
|
2010-10-12 08:18:49 -04:00
|
|
|
git archive $releaseVersion | tar -x -C $exportDirectory
|
2010-09-12 18:47:21 -04:00
|
|
|
fi
|
2010-10-12 08:30:16 -04:00
|
|
|
|
|
|
|
# So far all changes were locally. Still need to push them to the remote repo
|
|
|
|
git push --tags
|