2016-06-20 12:08:53 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "-----------------------------------------------"
|
|
|
|
echo " Verify Environment"
|
|
|
|
|
|
|
|
requiredExecutable() {
|
|
|
|
hash $1 2>/dev/null
|
|
|
|
if [ $? != 0 ] ; then
|
|
|
|
echo "ERROR: $1 not found. Install $1"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
requiredExecutable "git"
|
|
|
|
requiredExecutable "xmllint"
|
|
|
|
requiredExecutable "sed"
|
|
|
|
requiredExecutable "gpg"
|
|
|
|
requiredExecutable "egrep"
|
|
|
|
requiredExecutable "mvn"
|
|
|
|
|
|
|
|
proceedyn() {
|
|
|
|
while true; do
|
|
|
|
read -p "$1 " yn
|
|
|
|
case ${yn:-$2} in
|
|
|
|
[Yy]* ) return 0;;
|
|
|
|
[Nn]* ) return 1;;
|
|
|
|
* ) echo "Please answer yes or no.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "-----------------------------------------------"
|
|
|
|
echo " Collect Information About Release"
|
|
|
|
|
|
|
|
function gitFindRemoteByUrl() {
|
|
|
|
URL="$1"
|
|
|
|
for GREMOTE in $(git remote); do
|
|
|
|
git ls-remote --get-url $GREMOTE | grep "$URL" 2>&1 > /dev/null
|
|
|
|
if [ $? -eq 0 ] ; then
|
|
|
|
echo $GREMOTE
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-10-14 13:33:33 -04:00
|
|
|
GIT_REMOTE_URL="github.com:eclipse/jetty.project.git"
|
2016-06-20 12:08:53 -04:00
|
|
|
GIT_REMOTE_ID=$(gitFindRemoteByUrl "$GIT_REMOTE_URL")
|
|
|
|
GIT_BRANCH_ID=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
|
|
|
|
|
|
|
|
if [ -z "$GIT_REMOTE_ID" ] ; then
|
|
|
|
echo "ERROR: Unable to determine git remote id for $GIT_REMOTE_URL"
|
|
|
|
echo "Are you running this build from a properly cloned git local repository?"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure that git user is in their gpg key list
|
|
|
|
GIT_USER_EMAIL=`git config --get user.email`
|
|
|
|
|
|
|
|
#gpg -q --list-keys "$GIT_USER_EMAIL" 2>&1 > /dev/null
|
|
|
|
#if [ $? != 0 ] ; then
|
|
|
|
# echo "ERROR: git user.email of $GIT_USER_EMAIL is not present in your gpg --list-keys"
|
|
|
|
# echo "Go ahead and make one $ gpg --gen-key"
|
|
|
|
# exit -1
|
|
|
|
#fi
|
|
|
|
|
|
|
|
VER_CURRENT=`sed -e "s/xmlns/ignore/" pom.xml | xmllint --xpath "/project/version/text()" -`
|
2016-12-22 12:45:45 -05:00
|
|
|
echo "Current pom.xml Version: ${VER_CURRENT}"
|
2016-06-20 12:08:53 -04:00
|
|
|
read -e -p "Release Version ? " VER_RELEASE
|
|
|
|
read -e -p "Next Dev Version ? " VER_NEXT
|
|
|
|
TAG_NAME="jetty-$VER_RELEASE"
|
|
|
|
|
|
|
|
# Ensure tag doesn't exist (yet)
|
|
|
|
git rev-parse --quiet --verify "$TAG_NAME" 2>&1 > /dev/null
|
|
|
|
if [ $? -eq 0 ] ; then
|
|
|
|
echo ""
|
|
|
|
echo "ERROR: Git Tag $TAG_NAME already exists"
|
|
|
|
echo ""
|
|
|
|
git show -s "$TAG_NAME"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ALT_DEPLOY_DIR=$HOME/.m2/alt-deploy
|
|
|
|
if [ ! -d "$ALT_DEPLOY_DIR" ] ; then
|
|
|
|
mkdir -p "$ALT_DEPLOY_DIR"
|
|
|
|
fi
|
|
|
|
|
2016-12-22 12:45:45 -05:00
|
|
|
# DEPLOY_OPTS="-Dmaven.test.failure.ignore=true"
|
2019-06-10 09:10:34 -04:00
|
|
|
DEPLOY_OPTS="-DskipTests -Dtest=None"
|
2016-06-20 12:08:53 -04:00
|
|
|
# DEPLOY_OPTS="$DEPLOY_OPTS -DaltDeploymentRepository=intarget::default::file://$ALT_DEPLOY_DIR/"
|
|
|
|
|
2019-06-10 09:10:34 -04:00
|
|
|
# Uncomment for Java 1.7
|
|
|
|
export MAVEN_OPTS="-Xmx1g -XX:MaxPermSize=128m"
|
|
|
|
|
2016-06-20 12:08:53 -04:00
|
|
|
echo ""
|
|
|
|
echo "-----------------------------------------------"
|
|
|
|
echo " Release Plan Review"
|
|
|
|
echo ""
|
|
|
|
echo "Git Remote ID : $GIT_REMOTE_ID"
|
|
|
|
echo "Git Branch ID : $GIT_BRANCH_ID"
|
|
|
|
echo "Git user.email : $GIT_USER_EMAIL"
|
|
|
|
echo "Current Version : $VER_CURRENT"
|
|
|
|
echo "Release Version : $VER_RELEASE"
|
|
|
|
echo "Next Dev Version : $VER_NEXT"
|
|
|
|
echo "Tag name : $TAG_NAME"
|
2019-06-10 09:10:34 -04:00
|
|
|
echo "MAVEN_OPTS : $MAVEN_OPTS"
|
2016-06-20 12:08:53 -04:00
|
|
|
echo "Maven Deploy Opts: $DEPLOY_OPTS"
|
|
|
|
|
|
|
|
reportMavenTestFailures() {
|
|
|
|
failFiles=$(egrep -lr --include="*.txt" -E "^Tests .* FAILURE" .)
|
|
|
|
oldIFS="$IFS"
|
|
|
|
IFS='
|
|
|
|
'
|
|
|
|
IFS=${IFS:0:1}
|
|
|
|
failarray=( $failFiles )
|
|
|
|
IFS="$oldIFS"
|
|
|
|
|
|
|
|
for index in ${!failarray[@]}; do
|
|
|
|
echo ${failarray[index]}
|
|
|
|
cat ${failarray[index]}
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${#failarray[@]} -gt 0 ] ; then
|
|
|
|
echo "There are ${#failarray[@]} Test Cases with failures"
|
|
|
|
else
|
|
|
|
echo "There are no testcases with failures"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
if proceedyn "Are you sure you want to release using above? (y/N)" n; then
|
|
|
|
echo ""
|
|
|
|
if proceedyn "Update VERSION.txt for $VER_RELEASE? (Y/n)" y; then
|
2019-06-10 09:10:34 -04:00
|
|
|
# Uncomment alternate JVM for jetty 9.2 builds
|
|
|
|
# JAVA_HOME_ORIG=$JAVA_HOME
|
|
|
|
# PATH_ORIG=$PATH
|
|
|
|
# JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
|
|
|
|
# PATH=$JAVA_HOME/bin:$PATH
|
2016-12-22 12:45:45 -05:00
|
|
|
mvn -N -Pupdate-version generate-resources
|
2016-06-20 12:08:53 -04:00
|
|
|
cp VERSION.txt VERSION.txt.backup
|
|
|
|
cat VERSION.txt.backup | sed -e "s/$VER_CURRENT/$VER_RELEASE/" > VERSION.txt
|
|
|
|
rm VERSION.txt.backup
|
2019-06-10 09:10:34 -04:00
|
|
|
# JAVA_HOME=$JAVA_HOME_ORIG
|
|
|
|
# PATH=$PATH_ORIG
|
2016-12-22 12:45:45 -05:00
|
|
|
echo "VERIFY the following files (in a different console window) before continuing."
|
|
|
|
echo " VERSION.txt - top section"
|
2019-06-10 09:10:34 -04:00
|
|
|
echo " target/version-tag.txt - for the tag commit message"
|
2016-06-20 12:08:53 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# This is equivalent to 'mvn release:prepare'
|
|
|
|
if proceedyn "Update project.versions for $VER_RELEASE? (Y/n)" y; then
|
2019-04-02 21:34:46 -04:00
|
|
|
mvn org.codehaus.mojo:versions-maven-plugin:2.7:set \
|
2016-06-20 12:08:53 -04:00
|
|
|
-DoldVersion="$VER_CURRENT" \
|
2017-09-25 20:25:50 -04:00
|
|
|
-DnewVersion="$VER_RELEASE" \
|
|
|
|
-DprocessAllModules=true
|
2016-06-20 12:08:53 -04:00
|
|
|
fi
|
|
|
|
if proceedyn "Commit $VER_RELEASE updates? (Y/n)" y; then
|
|
|
|
git commit -a -m "Updating to version $VER_RELEASE"
|
|
|
|
fi
|
|
|
|
if proceedyn "Create Tag $TAG_NAME? (Y/n)" y; then
|
|
|
|
echo "TODO: Sign tags with GIT_USER_EMAIL=$GIT_USER_EMAIL"
|
2019-06-10 09:10:34 -04:00
|
|
|
echo "Using target/version-tag.txt as tag text"
|
|
|
|
git tag --file=target/version-tag.txt $TAG_NAME
|
2016-06-20 12:08:53 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# This is equivalent to 'mvn release:perform'
|
|
|
|
if proceedyn "Build/Deploy from tag $TAG_NAME? (Y/n)" y; then
|
|
|
|
git checkout $TAG_NAME
|
2020-05-30 07:28:33 -04:00
|
|
|
mvn clean package javadoc:aggregate-jar deploy \
|
2016-06-20 12:08:53 -04:00
|
|
|
-Peclipse-release $DEPLOY_OPTS
|
|
|
|
reportMavenTestFailures
|
|
|
|
git checkout $GIT_BRANCH_ID
|
|
|
|
fi
|
|
|
|
if proceedyn "Update working directory for $VER_NEXT? (Y/n)" y; then
|
|
|
|
echo "Update VERSION.txt for $VER_NEXT"
|
|
|
|
cp VERSION.txt VERSION.txt.backup
|
|
|
|
echo "jetty-$VER_NEXT" > VERSION.txt
|
|
|
|
echo "" >> VERSION.txt
|
|
|
|
cat VERSION.txt.backup >> VERSION.txt
|
|
|
|
echo "Update project.versions for $VER_NEXT"
|
2019-06-10 09:10:34 -04:00
|
|
|
mvn org.codehaus.mojo:versions-maven-plugin:2.7:set \
|
2016-06-20 12:08:53 -04:00
|
|
|
-DoldVersion="$VER_RELEASE" \
|
2019-06-10 09:10:34 -04:00
|
|
|
-DnewVersion="$VER_NEXT" \
|
|
|
|
-DprocessAllModules=true
|
2016-06-20 12:08:53 -04:00
|
|
|
echo "Commit $VER_NEXT"
|
|
|
|
if proceedyn "Commit updates in working directory for $VER_NEXT? (Y/n)" y; then
|
|
|
|
git commit -a -m "Updating to version $VER_NEXT"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if proceedyn "Push git commits to remote $GIT_REMOTE_ID? (Y/n)" y; then
|
|
|
|
git push $GIT_REMOTE_ID $GIT_BRANCH_ID
|
2019-10-24 07:34:50 -04:00
|
|
|
git push $GIT_REMOTE_ID $TAG_NAME
|
2016-06-20 12:08:53 -04:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Not performing release"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|