Skip to content

Instantly share code, notes, and snippets.

@rm5248
Created August 17, 2016 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rm5248/f8a0838bf9d03e0e6104bec41374e284 to your computer and use it in GitHub Desktop.
Save rm5248/f8a0838bf9d03e0e6104bec41374e284 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Steps for a release:
#
# 1. Ensure that the working directory is clean
# 2. Create a tag in SVN
# 3. build software
# 4. package software
# 5. build website
# 6. Copy all artifacts to specified directory
#
# Variables that may be useful
#
REPOSITORY_ROOT=$(svn info | grep "Repository Root" | awk '{print $3}')
REPOSITORY_URL=$(svn info | grep "^URL: " | awk '{print $2}')
REPOSITORY_TAG_URL=$REPOSITORY_ROOT/tags
DIST_ARCHIVE_NAME=log4cxx-0.11.0
echo "REPOSITORY_ROOT $REPOSITORY_ROOT"
echo "TAG_URL $REPOSITORY_TAG_URL"
echo "REPOSITORY_URL $REPOSITORY_URL"
#exit 0
ensure_clean_directory(){
is_clean=$(svn status -q | wc -l)
return $is_clean
}
check_realclean(){
is_realclean=$(svn status | wc -l)
return $is_realclean
}
svn_tag(){
echo "Copy $REPOSITORY_URL to $REPOSITORY_TAG_URL/$1"
svn cp "$REPOSITORY_URL" "$REPOSITORY_TAG_URL"/"$1" -m "[Tagging version $1]"
if [ $? -ne 0 ]
then
echo "Unable to tag"
exit 1
fi
}
build_software(){
mkdir target_build
svn co "$REPOSITORY_TAG_URL"/"$1" target_build
cd target_build
./autogen.sh
./configure
make
if [ $? -ne 0 ]
then
echo "ERROR: Release failed! Unable to build"
exit 1
fi
make check
if [ $? -ne 0 ]
then
echo "ERROR: Release failed! Tests failed"
exit 1
fi
make dist-gzip
make dist-zip
cd ..
# copy the generated .tar.gz and .zip files to our deliverables directory
cp target_build/"$DIST_ARCHIVE_NAME".tar.gz deliverables
cp target_build/"$DIST_ARCHIVE_NAME".zip deliverables
}
build_website(){
cd target_build
mvn site:site
cd ..
}
main(){
echo "======================================"
echo "Prepare for release"
echo "======================================"
ensure_clean_directory
is_clean=$?
if [ $is_clean -ne 0 ]
then
echo "Directory not clean, aborting release process"
echo "Ensure that all files have been committed"
exit 1
fi
check_realclean
realclean=$?
if [ $realclean -ne 0 ]
then
read -p "WARNING: Directory has generated and/or uncommitted files, abort? [Y/n] " abort
if [ $abort != "n" ]
then
exit 0
fi
fi
echo "======================================"
echo "Updating Maven"
echo "======================================"
read -p "Input release version: " version
read -p "Input new SNAPSHOT version: " snapshot
mvn versions:set -DnewVersion="$version"
svn commit -m "[Updated Version]" pom.xml
echo "======================================"
echo "Tagging in SVN"
echo "======================================"
read -p "Input tag name: " tag_name
svn_tag $tag_name
mvn versions:set -DnewVersion="$snapshot"
svn commit -m "[Updated Dev Version]" pom.xml
echo "======================================"
echo "Building Software"
echo "======================================"
mkdir deliverables
build_software $tag_name
echo "======================================"
echo "Building Website"
echo "======================================"
build_website
cp -r target_build/target/site deliverables
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment