release.sh | 186 +++++++++++++++++++++++++++--------------------------------
rhq_bash.lib | 28 ++++++++
2 files changed, 116 insertions(+), 98 deletions(-)
New commits:
commit 2aa9a9acd4f4db0a8346041918740b57989f7b29
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Sep 29 16:32:27 2011 -0500
Abort the script if local or remote tags already exist. This should never happen
regardless of the script mode.
diff --git a/release.sh b/release.sh
index 5d598ed..629e30f 100755
--- a/release.sh
+++ b/release.sh
@@ -259,22 +259,14 @@ fi
# If the specified tag already exists remotely and we're in production mode, then
abort. If it exists and
# we're in test mode, delete it
EXISTING_REMOTE_TAG=`git ls-remote --tags origin "$RELEASE_TAG"`
-if [ -n "$EXISTING_REMOTE_TAG" ] && [ "$MODE" =
"production" ]; then
- abort "A remote tag named $RELEASE_TAG already exists - aborting, since we are in
production mode..."
-fi
-
-if [ -n "$EXISTING_REMOTE_TAG" ] && [ "$MODE" =
"test" ]; then
- echo "A remote tag named $RELEASE_TAG already exists - deleting it, since we are
in test mode..."
- git push origin ":refs/tags/$RELEASE_TAG"
- [ "$?" -ne 0 ] && abort "Failed to delete remote tag
($RELEASE_TAG)."
+if [ -n "$EXISTING_REMOTE_TAG" ] then
+ abort "A remote tag named $RELEASE_TAG already exists - aborting"
fi
# See if the specified tag already exists locally - if so, delete it (even if in
production mode).
EXISTING_LOCAL_TAG=`git tag -l "$RELEASE_TAG"`
if [ -n "$EXISTING_LOCAL_TAG" ]; then
- echo "A local tag named $RELEASE_TAG already exists - deleting it..."
- git tag -d "$RELEASE_TAG"
- [ "$?" -ne 0 ] && abort "Failed to delete local tag
($RELEASE_TAG)."
+ abort "A local tag named $RELEASE_TAG already exists - aborting"
fi
run_versioning_process
commit ed45d1efe4fe62b80be813b7c7f81a4923cacf2f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Sep 29 16:20:07 2011 -0500
Introduce the concept of script mode and add it to the command line arguments.
diff --git a/release.sh b/release.sh
index 17be5b2..5d598ed 100755
--- a/release.sh
+++ b/release.sh
@@ -31,37 +31,31 @@ abort()
#===================================================================================
usage()
{
- abort "$@" "Usage: $EXE community|enterprise RELEASE_VERSION
DEVELOPMENT_VERSION RELEASE_BRANCH GIT_USERNAME test|production" "Example: $EXE
enterprise 3.0.0.GA 3.0.0-SNAPSHOT release-3.0.0 ips test"
+ abort "$@" "Usage: $EXE branch|tag community|enterprise
RELEASE_VERSION DEVELOPMENT_VERSION RELEASE_BRANCH GIT_USERNAME test|production"
"Example: $EXE enterprise 3.0.0.GA 3.0.0-SNAPSHOT release-3.0.0 ips test"
}
-#===================================================================================
-# Description: Set all the local and environment variables required by the script.
-#===================================================================================
-set_variables()
-{
- # Constants
-
- PROJECT_NAME="rhq"
- PROJECT_DISPLAY_NAME="RHQ"
-
PROJECT_GIT_WEB_URL="http://git.fedorahosted.org/git/?p=rhq/rhq.git&...
- TAG_PREFIX="RHQ"
- MINIMUM_MAVEN_VERSION="2.1.0"
+validate_arguments()
+{
# Process command line args.
EXE=`basename $0`
- if [ "$#" -ne 6 ]; then
+ if [ "$#" -ne 7 ]; then
usage
- fi
- RELEASE_TYPE="$1"
+ fi
+
+ SCRIPT_MODE="$1"
+
+ RELEASE_TYPE="$2"
if [ "$RELEASE_TYPE" != "community" ] && [
"$RELEASE_TYPE" != "enterprise" ]; then
usage "Invalid release type: $RELEASE_TYPE (valid release types are
'community' or 'enterprise')"
fi
- RELEASE_VERSION="$2"
- DEVELOPMENT_VERSION="$3"
- RELEASE_BRANCH="$4"
- GIT_USERNAME="$5"
- MODE="$6"
+ RELEASE_VERSION="$3"
+ DEVELOPMENT_VERSION="$4"
+ RELEASE_BRANCH="$5"
+ GIT_USERNAME="$6"
+ MODE="$7"
+
if [ "$MODE" != "test" ] && [ "$MODE" !=
"production" ]; then
usage "Invalid mode: $MODE (valid modes are 'test' or
'production')"
fi
@@ -71,13 +65,26 @@ set_variables()
usage "In production mode,
jboss.org credentials must be specified via the
JBOSS_ORG_USERNAME and JBOSS_ORG_PASSWORD environment variables."
fi
fi
+}
+
+#===================================================================================
+# Description: Set all the local and environment variables required by the script.
+#===================================================================================
+set_variables()
+{
+ # Constants
+
+ PROJECT_NAME="rhq"
+ PROJECT_DISPLAY_NAME="RHQ"
+
PROJECT_GIT_WEB_URL="http://git.fedorahosted.org/git/?p=rhq/rhq.git&...
+ TAG_PREFIX="RHQ"
+ MINIMUM_MAVEN_VERSION="2.1.0"
# Set various environment variables.
MAVEN_OPTS="-Xms512M -Xmx1024M -XX:PermSize=128M -XX:MaxPermSize=256M"
export MAVEN_OPTS
-
# Set various local variables.
if [ -n "$HUDSON_URL" ] && [ -n "$WORKSPACE" ]; then
@@ -167,6 +174,8 @@ fi
# TODO: Check that JDK version is < 1.7.
+validate_arguments $@
+
validate_java_6
validate_java_5
@@ -175,7 +184,7 @@ validate_maven
validate_git
-set_variables $@
+set_variables
# Print out a summary of the environment.
print_centered "Environment Variables"
commit 9aa53e6a0538815a47846901fe5b46bca5f1ad5b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Sep 29 15:49:02 2011 -0500
Added documentation for existing functions. Also, done a little refactoring to make
the main script more legible.
diff --git a/release.sh b/release.sh
index 5a4bf7f..17be5b2 100755
--- a/release.sh
+++ b/release.sh
@@ -1,9 +1,22 @@
-#!/bin/sh
-
+#!/bin/bash
+#===================================================================================
+#
+# Usage: release.sh community|enterprise RELEASE_VERSION DEVELOPMENT_VERSION
RELEASE_BRANCH GIT_USERNAME test|production
+#
+# Description:
+# Add description here
+#
+# Options:
+# Add option description here
+#===================================================================================
+
+#include the utility library
source `dirname $0`/rhq_bash.lib
-# Functions
+#===================================================================================
+# Description: Display an error message and abort the script.
+#===================================================================================
abort()
{
echo >&2
@@ -13,11 +26,17 @@ abort()
exit 1
}
+#===================================================================================
+# Description: Display usage information then abort the script.
+#===================================================================================
usage()
{
abort "$@" "Usage: $EXE community|enterprise RELEASE_VERSION
DEVELOPMENT_VERSION RELEASE_BRANCH GIT_USERNAME test|production" "Example: $EXE
enterprise 3.0.0.GA 3.0.0-SNAPSHOT release-3.0.0 ips test"
}
+#===================================================================================
+# Description: Set all the local and environment variables required by the script.
+#===================================================================================
set_variables()
{
# Constants
@@ -113,6 +132,10 @@ set_variables()
export LANG
}
+#===================================================================================
+# Description: Perform version update process and test the outcome by building
+# from source.
+#===================================================================================
run_versioning_process()
{
# Clean up the snapshot jars produced by the test build from module target dirs.
@@ -152,15 +175,15 @@ validate_maven
validate_git
-set_variables
+set_variables $@
# Print out a summary of the environment.
-echo "========================== Environment Variables
=============================="
+print_centered "Environment Variables"
environment_variables=("JAVA_HOME" "M2_HOME" "MAVEN_OPTS"
"PATH" "LANG" "RELEASE_TYPE")
print_variables "${environment_variables[@]}"
-echo "============================= Local Variables
================================="
+print_centered "Local Variables"
local_variables=("WORKING_DIR" "PROJECT_NAME"
"PROJECT_GIT_URL" "RELEASE_TYPE" "DEVELOPMENT_VERSION" \
"RELEASE_BRANCH" "MODE"
"MAVEN_LOCAL_REPO_DIR" \
"MAVEN_SETTINGS_FILE" "MAVEN_ARGS"
"MAVEN_RELEASE_PERFORM_GOAL" "JBOSS_ORG_USERNAME" \
@@ -168,11 +191,13 @@ local_variables=("WORKING_DIR" "PROJECT_NAME"
"PROJECT_GIT_URL" "RELEASE_TYPE" "
print_variables "${local_variables[@]}"
-echo "============================= Program Versions
================================"
+print_centered "Program Versions"
program_versions=("git --version" "java -version" "mvn
--version")
print_program_versions "${program_versions[@]}"
-echo
"==============================================================================="
+print_centered "="
+
+exit
# Checkout the source from git, assume that the git repo is already cloned
git status >/dev/null 2>&1
@@ -221,14 +246,9 @@ else
git pull origin "$BUILD_BRANCH"
git push origin "$BUILD_BRANCH"
fi
-
-
-# We should now have the build_branch checked out
-echo "Current Branch is $BUILD_BRANCH"
# If the specified tag already exists remotely and we're in production mode, then
abort. If it exists and
# we're in test mode, delete it
-
EXISTING_REMOTE_TAG=`git ls-remote --tags origin "$RELEASE_TAG"`
if [ -n "$EXISTING_REMOTE_TAG" ] && [ "$MODE" =
"production" ]; then
abort "A remote tag named $RELEASE_TAG already exists - aborting, since we are in
production mode..."
@@ -240,7 +260,6 @@ if [ -n "$EXISTING_REMOTE_TAG" ] && [
"$MODE" = "test" ]; then
[ "$?" -ne 0 ] && abort "Failed to delete remote tag
($RELEASE_TAG)."
fi
-
# See if the specified tag already exists locally - if so, delete it (even if in
production mode).
EXISTING_LOCAL_TAG=`git tag -l "$RELEASE_TAG"`
if [ -n "$EXISTING_LOCAL_TAG" ]; then
diff --git a/rhq_bash.lib b/rhq_bash.lib
index 19d76da..7c1229b 100644
--- a/rhq_bash.lib
+++ b/rhq_bash.lib
@@ -132,3 +132,31 @@ validate_git()
abort "Unsupported git version - $GIT_VERSION. Only git 1.6.x or 1.7.x are
supported. Please add a directory containing a supported version of git to your PATH, then
try again."
fi
}
+
+print_centered()
+{
+ max_length=90
+ string_length=${#1}
+
+ if [ $string_length -ge `expr $max_length - 2` ]
+ then
+ echo $1
+ return 0
+ fi
+
+ left_side=`expr $max_length - $string_length`
+ left_side=`expr $left_side / 2`
+
+ is_odd_number=$(( $string_length % 2 ))
+ if [ $is_odd_number -eq 0 ]
+ then
+ right_side=$left_side
+ else
+ right_side=`expr $left_side + 1 `
+ fi
+
+ eval "printf '=%.0s' {1..${left_side}}"
+ printf " $1 "
+ eval "printf '=%.0s' {1..${right_side}}"
+ printf "\n"
+}
commit 942491f72ee57adf050255febd589775af94d45f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Sep 29 14:35:38 2011 -0500
Replace maven release plugin with versions plugin. Also removed all the code that will
not be use going forward.
diff --git a/release.sh b/release.sh
index b3491ad..5a4bf7f 100755
--- a/release.sh
+++ b/release.sh
@@ -113,6 +113,30 @@ set_variables()
export LANG
}
+run_versioning_process()
+{
+ # Clean up the snapshot jars produced by the test build from module target dirs.
+ echo "Cleaning up snapshot jars produced by test build from module target
dirs..."
+ mvn clean $MAVEN_ARGS
+ [ "$?" -ne 0 ] && abort "Failed to cleanup snbapshot jars
produced by test build from module target dirs. Please see above Maven output for details,
fix any issues, then try again."
+
+ mvn install $MAVEN_ARGS -Ddbreset
+ [ "$?" -ne 0 ] && abort "Test build failed. Please see output
for details, fix any issues, then try again."
+
+ mvn versions:set versions:use-releases -DnewVersion=$RELEASE_VERSION
-DallowSnapshots=false -DgenerateBackupPoms=false
+ [ "$?" -ne 0 ] && abort "Version set failed. Please see output
for details, fix any issues, then try again."
+
+ mvn install $MAVEN_ARGS -DskipTests=true -Ddbsetup-do-not-check-schema=true
+ [ "$?" -ne 0 ] && abort "Maven build for new version failed.
Please see output for details, fix any issues, then try again."
+
+ mvn versions:set versions:use-releases -DnewVersion=$DEVELOPMENT_VERSION
-DallowSnapshots=false -DgenerateBackupPoms=false
+ [ "$?" -ne 0 ] && abort "Version set failed. Please see output
for details, fix any issues, then try again."
+
+ #echo "Building release from tag and publishing Maven artifacts (this will take
about 10-15 minutes)..."
+ #mvn $MAVEN_RELEASE_PERFORM_GOAL $MAVEN_ARGS -Dmaven.test.skip=true
-Ddbsetup-do-not-check-schema=true
+ #[ "$?" -ne 0 ] && abort "Release build failed. Please see
above Maven output for details, fix any issues, then try again."
+}
+
if [ -n "$RELEASE_DEBUG" ]; then
echo "Debug output is enabled."
set -x
@@ -144,7 +168,6 @@ local_variables=("WORKING_DIR" "PROJECT_NAME"
"PROJECT_GIT_URL" "RELEASE_TYPE" "
print_variables "${local_variables[@]}"
-
echo "============================= Program Versions
================================"
program_versions=("git --version" "java -version" "mvn
--version")
print_program_versions "${program_versions[@]}"
@@ -219,67 +242,14 @@ fi
# See if the specified tag already exists locally - if so, delete it (even if in
production mode).
-
EXISTING_LOCAL_TAG=`git tag -l "$RELEASE_TAG"`
if [ -n "$EXISTING_LOCAL_TAG" ]; then
echo "A local tag named $RELEASE_TAG already exists - deleting it..."
git tag -d "$RELEASE_TAG"
[ "$?" -ne 0 ] && abort "Failed to delete local tag
($RELEASE_TAG)."
fi
-
-# Run a test build before tagging. This will publish the snapshot artifacts to the local
repo to "bootstrap" the repo.
-
-#echo "Building project to ensure tests pass and to bootstrap local Maven repo (this
will take about 15-30 minutes)..."
-# NOTE: There is no need to do a mvn clean below, since we just did either a clone or
clean checkout above.
-#mvn install $MAVEN_ARGS -Ddbreset
-#[ "$?" -ne 0 ] && abort "Test build failed. Please see above
Maven output for details, fix any issues, then try again."
-#echo
-#echo "Test build succeeded!"
-
-
-# Clean up the snapshot jars produced by the test build from module target dirs.
-
-echo "Cleaning up snapshot jars produced by test build from module target
dirs..."
-mvn clean $MAVEN_ARGS
-[ "$?" -ne 0 ] && abort "Failed to cleanup snbapshot jars produced
by test build from module target dirs. Please see above Maven output for details, fix any
issues, then try again."
-
-
-# If this is a production build perform a dry run of tagging the release. Skip this for
test builds to reduce the
-# build time
-
-if [ "$MODE" = "todo" ]; then
- echo "Doing a dry run of tagging the release..."
- mvn release:prepare $MAVEN_ARGS -DreleaseVersion=$RELEASE_VERSION
-DdevelopmentVersion=$DEVELOPMENT_VERSION -Dresume=false -Dtag=$RELEASE_TAG
"-DpreparationGoals=install $MAVEN_ARGS -DskipTests=true
-Ddbsetup-do-not-check-schema=true" -DdryRun=true
- [ "$?" -ne 0 ] && abort "Tagging dry run failed. Please see
above Maven output for details, fix any issues, then try again."
- mvn release:clean $MAVEN_ARGS
- [ "$?" -ne 0 ] && abort "Failed to cleanup release plugin
working files from tagging dry run. Please see above Maven output for details, fix any
issues, then try again."
- echo
- echo "Tagging dry run succeeded!"
-fi
-
-
-# If the dry run was skipped or succeeded, tag it for real.
-
-echo "Tagging the release..."
-mvn release:prepare $MAVEN_ARGS -DreleaseVersion=$RELEASE_VERSION
-DdevelopmentVersion=$DEVELOPMENT_VERSION -Dresume=false -Dtag=$RELEASE_TAG
"-DpreparationGoals=install $MAVEN_ARGS -DskipTests=true
-Ddbsetup-do-not-check-schema=true" -DdryRun=false -Dusername=$GIT_USERNAME
-[ "$?" -ne 0 ] && abort "Tagging failed. Please see above Maven
output for details, fix any issues, then try again."
-echo
-echo "Tagging succeeded!"
-
-
-# Checkout the tag and build it. If in production mode, publish the Maven artifacts.
-
-#echo "Checking out release tag $RELEASE_TAG..."
-#git checkout "$RELEASE_TAG"
-#[ "$?" -ne 0 ] && abort "Checkout of release tag ($RELEASE_TAG)
failed. Please see above git output for details, fix any issues, then try again."
-#git clean -dxf
-#[ "$?" -ne 0 ] && abort "Failed to cleanup unversioned files.
Please see above git output for details, fix any issues, then try again."
-#echo "Building release from tag and publishing Maven artifacts (this will take
about 10-15 minutes)..."
-#mvn $MAVEN_RELEASE_PERFORM_GOAL $MAVEN_ARGS -Dmaven.test.skip=true
-Ddbsetup-do-not-check-schema=true
-#[ "$?" -ne 0 ] && abort "Release build failed. Please see above
Maven output for details, fix any issues, then try again."
-#echo
-#echo "Release build succeeded!"
+run_versioning_process
echo
echo "=============================== Release Info
=================================="