Skip to content

Commit

Permalink
GEOS-5200, updating release scripts for git switchover
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeolive committed Jul 4, 2012
1 parent 9eaa05c commit acea796
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 88 deletions.
137 changes: 61 additions & 76 deletions build/build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,25 @@ function usage() {
echo "$0 [options] <tag>"
echo
echo " tag : Release tag (eg: 2.1.4, 2.2-beta1, ...)"
echo " tag : Release tag (eg: 2.1.4, 2.2-beta1, ...)"
echo
echo "Options:"
echo " -h : Print usage"
echo " -b <branch> : Branch to release from (eg: trunk, 2.1.x, ...)"
echo " -r <rev> : Revision to release (eg: 12345)"
echo " -g <ver> : GeoTools version/revision (eg: 2.7.4, trunk:12345)"
echo " -w <ver> : GeoWebCache version/revision (eg: 1.3-RC1, stable:abcd)"
echo " -u <user> : Subversion username"
echo " -p <passwd> : Subversion password"
echo " -u <user> : git username"
echo " -e <passwd> : git email"
echo
echo "Environment variables:"
echo " BUILD_FROM_BRANCH : Builds release from branch rather than tag"
echo " SKIP_SVN_TAG : Skips creation of svn tag"
echo " SKIP_BUILD : Skips main release build"
echo " SKIP_INSTALLERS : Skips building of mac and windows installers"
echo " SKIP_GT : Skips the GeoTools build"
echo " SKIP_GWC : Skips the GeoWebCache build"
}

# parse options
while getopts "hb:r:g:w:u:p:" opt; do
while getopts "hb:r:g:w:u:e:" opt; do
case $opt in
h)
usage
Expand All @@ -48,10 +45,10 @@ while getopts "hb:r:g:w:u:p:" opt; do
gwc_ver=$OPTARG
;;
u)
svn_user=$OPTARG
git_user=$OPTARG
;;
p)
svn_passwd=$OPTARG
e)
git_email=$OPTARG
;;
\?)
usage
Expand All @@ -78,6 +75,16 @@ fi
. "$( cd "$( dirname "$0" )" && pwd )"/properties
. "$( cd "$( dirname "$0" )" && pwd )"/functions

# more sanity checks
if [ `is_version_num $tag` == "0" ]; then
echo "$tag is a not a valid release tag"
exit 1
fi
if [ `is_primary_branch_num $tag` == "1" ]; then
echo "$tag is a not a valid release tag, can't be same as primary branch name"
exit 1
fi

echo "Building release with following parameters:"
echo " branch = $branch"
echo " revision = $rev"
Expand All @@ -88,55 +95,36 @@ echo " geowebcache = $gwc_ver"
echo "maven/java settings:"
mvn -version

svn_opts="--username $svn_user --password $svn_passwd --non-interactive --trust-server-cert"

if [ "$branch" == "trunk" ]; then
svn_url=$SVN_ROOT/trunk
else
svn_url=$SVN_ROOT/branches/$branch
if [ ! -z $git_user ] && [ ! -z $git_email ]; then
git_opts="--author '$git_user <$git_email>'"
fi

if [ ! -z $BUILD_FROM_BRANCH ]; then
if [ ! -e tags/$tag ]; then
echo "checking out $svn_url"
svn co $svn_opts $svn_url tags/$tag
fi
else
# check if the svn tag already exists
if [ -z $SKIP_SVN_TAG ]; then
svn_tag_url=$SVN_ROOT/tags/$tag
set +e && svn ls $svn_opts $svn_tag_url >& /dev/null && set -e
if [ $? == 0 ]; then
# tag already exists
echo "svn tag $tag already exists, deleteing"
svn $svn_opts rm -m "removing $tag tag" $svn_tag_url
fi

# create svn tag
revopt="-r $rev"
if [ "$rev" == "latest" ]; then
revopt=""
fi

echo "Creating $tag tag from $branch ($rev) at $svn_tag_url"
svn cp $svn_opts -m "tagging $tag" $revopt $svn_url $svn_tag_url

# checkout newly created tag
if [ -e tags/$tag ]; then
# remove old checkout
rm -rf tags/$tag
fi

echo "checking out tag $tag"
svn $svn_opts co $svn_tag_url tags/$tag
fi
# move to root of source tree
pushd .. > /dev/null

# clear out any changes
git reset --hard HEAD

# checkout and update primary / release branches
git checkout rel_$branch
git pull origin rel_$branch
git checkout $branch
git pull origin $branch

# check to see if a release branch already exists
set +e && git checkout rel_$tag && set -e
if [ $? == 0 ]; then
# release branch already exists, kill it
git checkout $branch
echo "branch rel_$tag exists, deleting it"
git branch -D rel_$tag
fi

if [ ! -z $SKIP_SVN_TAG ] || [ ! -z $BUILD_FROM_BRANCH ]; then
echo "updating tag $tag"
svn revert --recursive tags/$tag
svn up tags/$tag
fi
# checkout the branch to release from
git checkout $branch

# create a release branch
git checkout -b rel_$tag $rev

# generate release notes
jira_id=`get_jira_id $tag`
Expand All @@ -146,7 +134,6 @@ if [ -z $jira_id ]; then
fi
echo "jira id = $jira_id"


# update README
#search?jql=project+%3D+%22GEOS%22+and+fixVersion+%3D+%222.2-beta2%22"

Expand All @@ -162,29 +149,31 @@ if [ -z $SKIP_GT ]; then
if [ -z $gt_tag ]; then
arr=(${gt_ver//@/ })
if [ "${#arr[@]}" != "2" ]; then
echo "Bad version $gt_ver, must be specified as <branch>:<revision>"
echo "Bad version $gt_ver, must be specified as <branch>@<revision>"
exit 1
fi

gt_branch=${arr[0]}
gt_rev=${arr[1]}
gt_dir=geotools/$gt_branch/$gt_rev
gt_dir=geotools
if [ ! -e $gt_dir ]; then
mkdir -p $gt_dir
echo "checking out geotools ${gt_branch}@${gt_rev}"
svn co -r $gt_rev $GT_SVN_ROOT/$gt_branch $gt_dir
echo "cloning geotools repo from $GT_GIT_URL"
git clone $GT_GIT_URL $gt_dir
fi

# build geotools
# checkout branch/rev
pushd $gt_dir > /dev/null
echo "checking out geotools ${gt_branch}@${gt_rev}"
git checkout $gt_rev

# build geotools
mvn clean install -DskipTests -Dall
popd > /dev/null

# derive the gt version
gt_tag=`get_pom_version $git_dir/pom.xml`
fi

fi
fi
fi

if [ ! -z $gt_tag ]; then
Expand Down Expand Up @@ -235,8 +224,6 @@ if [ ! -z $gwc_tag ]; then
echo "GeoWebCache version = $gwc_tag"
fi

pushd tags/$tag > /dev/null

# update geotools + geowebcache versions
if [ ! -z $gt_tag ]; then
sed -i "s/\(<gt.version>\).*\(<\/gt.version>\)/\1$gt_tag\2/g" src/pom.xml
Expand Down Expand Up @@ -283,9 +270,8 @@ find doc -name conf.py -exec sed -i "s/$old_ver/$tag/g" {} \;
pushd src/release > /dev/null
sed -i "s/$old_ver/$tag/g" *.xml installer/win/*.nsi installer/win/*.conf installer/mac/GeoServer.app/Contents/Info.plist
popd > /dev/null
popd > /dev/null

pushd tags/$tag/src > /dev/null
pushd src > /dev/null

# build the release
if [ -z $SKIP_BUILD ]; then
Expand Down Expand Up @@ -360,7 +346,7 @@ set +e && find . -type d -name target -exec rm -rf {} \; && set -e
rm ../$src
zip -r ../$src *

popd
popd > /dev/null
popd > /dev/null

echo "copying artifacts to $dist"
Expand All @@ -369,21 +355,20 @@ for a in `ls $artifacts/*.zip | grep -v plugin`; do
cp $a $dist
done

popd > /dev/null

# fire off mac and windows build machines
if [ -z $SKIP_INSTALLERS ]; then
echo "starting installer jobs"
start_installer_job $WIN_HUDSON $tag
start_installer_job $MAC_HUDSON $tag
fi

# svn commit changes on the tag
if [ -z $SKIP_SVN_TAG ]; then
pushd tags/$tag > /dev/null
svn commit $svn_opts -m "updating version numbers and release notes for $tag" .
popd > /dev/null
fi
# git commit changes on the release branch
pushd .. > /dev/null
git add .
git commit $git_opts -m "updating version numbers and release notes for $tag" .
popd > /dev/null

popd > /dev/null

echo "build complete, artifacts available at $DIST_URL/$tag"
exit 0
10 changes: 10 additions & 0 deletions build/functions
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ function start_installer_job() {
curl -k --connect-timeout 10 "$1/job/geoserver-installer/buildWithParameters?TAG=$2"
}

function is_primary_branch_num() {
local str=$1
if [ "$( echo $str | egrep "[0-9]+\.x" )" == "$str" ] || [ "master" == "$str" ]; then
echo "1"
else
echo "0"
fi

}

# is_version_nuym <str>
# tests a string to see if it is a x.y.z or x.y-z style version number
function is_version_num() {
Expand Down
3 changes: 1 addition & 2 deletions build/properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# as environment variables

# constants
SVN_ROOT=https://svn.codehaus.org/geoserver
GT_SVN_ROOT=http://svn.osgeo.org/geotools
GT_GIT_URL=git://github.com/geotools/geotools.git
GWC_GIT_URL=git://github.com/GeoWebCache/geowebcache.git
JIRA_REST=http://jira.codehaus.org/rest/api/latest
JIRA_PROJ=GEOS
Expand Down
76 changes: 66 additions & 10 deletions build/publish_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,95 @@

# error out if any statements fail
set -e
set -x

function usage() {
echo "$0 [options] <tag>"
echo "$0 [options] <tag> <branch>"
echo
echo " tag : Release tag (eg: 2.1.4, 2.2-beta1, ...)"
echo " branch: Release branch (eg, 2.1.x, 2.2.x)"
echo
echo "Environment variables:"
echo " SKIP_DEPLOY : Skips deploy to maven repository"
echo " SKIP_MERGE_AND_TAG : Skips merge/tag of release branch"
echo " SKIP_PUSH : Skips pushing changes to release branch and tag"
}

if [ -z $1 ]; then
if [ -z $2 ]; then
usage
exit
fi

tag=$1
branch=$2

# load properties + functions
. "$( cd "$( dirname "$0" )" && pwd )"/properties
. "$( cd "$( dirname "$0" )" && pwd )"/functions

if [ `is_version_num $tag` == "0" ]; then
echo "$tag is a not a valid release tag"
exit 1
fi
if [ `is_primary_branch_num $tag` == "1" ]; then
echo "$tag is a not a valid release tag, can't be same as primary branch name"
exit 1
fi

pushd .. > /dev/null

# switch to the release branch
git checkout rel_$tag

# ensure no changes on it
set +e
git status | grep "working directory clean"
if [ "$?" == "1" ]; then
echo "branch rel_$tag dirty, exiting"
exit 1
fi
set -e

# deploy the release to maven repo
pushd tags/$tag/src > /dev/null
mvn deploy -DskipTests
pushd src > /dev/null
if [ -z $SKIP_DEPLOY ]; then
mvn deploy -DskipTests
else
echo "Skipping mvn deploy -DskipTests"
fi

popd > /dev/null

# upload artifacts to sourceforge
pushd $DIST_PATH/$tag > /dev/null

rsync -ave "ssh -i $SF_PK" *.zip *.exe *.dmg $SF_USER@$SF_HOST:/home/pfs/project/g/ge/geoserver/GeoServer/$tag/
if [ -z $SKIP_DEPLOY ]; then
rsync -ave "ssh -i $SF_PK" *.zip *.exe *.dmg $SF_USER@$SF_HOST:/home/pfs/project/g/ge/geoserver/GeoServer/$tag/
pushd plugins > /dev/null
rsync -ave "ssh -i $SF_PK" *.zip $SF_USER@$SF_HOST:"/home/pfs/project/g/ge/geoserver/GeoServer\ Extensions/$tag/"
popd > /dev/null
else
echo "Skipping rsync -ave "ssh -i $SF_PK" *.zip *.exe *.dmg $SF_USER@$SF_HOST:/home/pfs/project/g/ge/geoserver/GeoServer/$tag/"
echo "Skipping rsync -ave "ssh -i $SF_PK" *.zip $SF_USER@$SF_HOST:"/home/pfs/project/g/ge/geoserver/GeoServer\ Extensions/$tag/""
fi

popd > /dev/null

pushd plugins > /dev/null
# merge the tag release branch into main release branch and tag it
git checkout rel_$branch
if [ -z $SKIP_MERGE_AND_TAG ]; then
git merge -m "Merging rel_$tag into rel_$branch" rel_$tag
git tag $tag
else
echo "Skipping git merge -m "Merging rel_$tag into rel_$branch" rel_$tag"
echo "Skipping git tag $tag"
fi

rsync -ave "ssh -i $SF_PK" *.zip $SF_USER@$SF_HOST:"/home/pfs/project/g/ge/geoserver/GeoServer\ Extensions/$tag/"
# push them up
if [ -z $SKIP_PUSH ]; then
git push origin rel_$branch
git push origin $tag
else
echo "Skipping git push origin rel_$branch"
echo "Skipping git push origin $tag"
fi

popd > /dev/null
popd > /dev/null

0 comments on commit acea796

Please sign in to comment.