From d921ffe1e3d248838487bdca8b18e2f1ba2dc717 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Sep 2015 11:25:30 +0200 Subject: [PATCH] Add the release shell script --- do-release.sh | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100755 do-release.sh diff --git a/do-release.sh b/do-release.sh new file mode 100755 index 0000000000..9414d9e3ed --- /dev/null +++ b/do-release.sh @@ -0,0 +1,299 @@ +#!/bin/bash + +# work around a maven-scm bug with git while releasing +# this might also be necessary: git config --add status.displayCommentPrefix true +# see https://jira.codehaus.org/browse/SCM-740 +export LANG=C + +export MAVEN_OPTS="-XX:MaxPermSize=1g" + + +# check setup +if [ "" = "$PMD_SF_USER" ]; then + echo "No env variable PMD_SF_USER specified. This is the sourceforge account name needed" + echo "during the release process to upload files via ssh/scp/rsync." + echo + echo "Please set the variable, e.g. in your ~/.bashrc:" + echo + echo "PMD_SF_USER=sfuser" + echo "export PMD_SF_USER" + echo + exit 1 +fi + +if [ "" = "$PMD_GPG_KEY" ]; then + echo "No env variable PMD_GPG_KEY specified. This is your gpg key, that will be used" + echo "to sign the created release artifacts before uploading to maven central." + echo + echo "Please set the variable, e.g. in your ~/.bashrc:" + echo + echo "PMD_GPG_KEY=AB123CDE" + echo "export PMD_GPG_KEY" + echo + exit 1 +fi + +# verify the current directory +if [ ! -f pom.xml -o ! -d ../pmd.github.io ]; then + echo "You seem to be in the work working directory or you don't have pmd.github.io checked out..." + echo + echo "Expected:" + echo "* You are currently in the pmd repository" + echo "* ../pmd.github.io is the pmd.github.io repository" + echo + exit 1 +fi + +########################################################################## + + +RELEASE_VERSION= +DEVELOPMENT_VERSION= +CURRENT_BRANCH= + +echo "-------------------------------------------" +echo "Releasing PMD" +echo "-------------------------------------------" + + +MVN_VERSION=$(mvn --version | grep "Java version: 1.6") +if [ $? -ne 0 ]; then + echo "Wrong java version!" + echo "Expected 1.6, but was:" + mvn --version + exit 1 +fi + + +if [ "" = "$RELEASE_VERSION" ]; then + echo -n "What is the release version of PMD? (e.g. 5.4.0) " + read RELEASE_VERSION +fi +if [ "" = "$DEVELOPMENT_VERSION" ]; then + echo -n "What is the next development version of PMD? (e.g. 5.5.0-SNAPSHOT) " + read DEVELOPMENT_VERSION +fi +if [ "" = "$CURRENT_BRANCH" ]; then + echo -n "What is the branch you wnat to release from? (e.g. master or pmd/5.3.x) " + read CURRENT_BRANCH +fi + +export RELEASE_VERSION +export DEVELOPMENT_VERSION +export CURRENT_BRANCH + +echo +echo +echo "* Update version/release info in **src/site/markdown/changelog.md**." +echo +echo " ## $(date -u +%d-%B-%Y) - ${RELEASE_VERSION}" +echo +echo "* Ensure all the new rules are listed in a the proper file:" +echo " pmd-core/src/main/resources/rulesets/releases/${RELEASE_VERSION}.xml file." +echo +echo "* Update **../pmd.github.io/latest/index.html** of our website, to redirect to the new version" +echo +echo "redirect_to: https://pmd.github.io/pmd-${RELEASE_VERSION}/" +echo +echo "* Update **../pmd.github.io/index.html** to mention the new release" +echo +echo +echo "Press enter to continue..." +read + +echo "first - running a test install..." + +mvn clean install +if [ $? -ne 0 ]; then + echo "Failure during test install...." + exit 1 +fi + +( + cd pmd-dist/target + unzip pmd-bin-*.zip + cd pmd-bin-* + ./bin/run.sh pmd -d ../../../pmd-java/src/main/java -language java -f xml -R rulesets/java/unusedcode.xml +) + +echo +echo "---- OK?" +echo "Press enter to continue..." +read + +echo "Committing current changes (pmd)" +git commit -a -m "Prepare pmd release ${RELEASE_VERSION}" +( + echo "Committing current changes (pmd.github.io)" + cd ../pmd.github.io + git commit -a -m "Prepare pmd release ${RELEASE_VERSION}" +) + + +mvn -B release:clean release:prepare \ + -Dtag=pmd_releases/${RELEASE_VERSION} \ + -DreleaseVersion=${RELEASE_VERSION} \ + -DdevelopmentVersion=${DEVELOPMENT_VERSION} +mvn -B release:perform + +( + cd target/checkout/ + + ( + cd pmd-dist/target + unzip pmd-bin-${RELEASE_VERSION}.zip + cd pmd-bin-${RELEASE_VERSION} + ./bin/run.sh pmd -d ../../../pmd-java/src/main/java -language java -f xml -R rulesets/java/unusedcode.xml + ) + +echo +echo "Verify once again..." +echo "---- OK?" +echo "Press enter to continue..." +read + +echo +echo "Generating site..." +mvn site site:stage +echo +echo "Press enter to continue..." +read + + +echo +echo "* Login to " +echo " Close and Release the staging repository" +echo " Check here: " +echo +echo "Press enter to continue..." +read + +echo +echo "Creating the pmd-doc-${RELEASE_VERSION}.zip archive..." +( + cd target + mv staging pmd-doc-${RELEASE_VERSION} + zip -r pmd-doc-${RELEASE_VERSION}.zip pmd-doc-${RELEASE_VERSION}/ +) + +echo +echo "Adding the site to pmd.github.io..." +rsync -avhP target/pmd-doc-${RELEASE_VERSION}/ ../../../pmd.github.io/pmd-${RELEASE_VERSION}/ +( + cd ../../../pmd.github.io + git add pmd-${RELEASE_VERSION} + git commit -m "Added pmd-${RELEASE_VERSION}" +) + +echo +echo "Uploading the zip files..." +rsync -avhP pmd-dist/target/pmd-*-${RELEASE_VERSION}.zip target/pmd-doc-${RELEASE_VERSION}.zip $SFUSER@web.sourceforge.net:/home/frs/project/pmd/pmd/${RELEASE_VERSION}/ +rsync -avhP src/site/markdown/overview/changelog.md $SFUSER@web.sourceforge.net:/home/frs/project/pmd/pmd/${RELEASE_VERSION}/ReadMe.md +echo + +if [ ! "" = "$PMD_LOCAL_BINARIES" -a -d $PMD_LOCAL_BINARIES ]; then +echo "Copying the files to local storage directory $PMD_LOCAL_BINARIES..." +cp -av pmd-dist/target/pmd-*-${RELEASE_VERSION}.zip target/pmd-doc-${RELEASE_VERSION}.zip $PMD_LOCAL_BINARIES +echo + + +echo +echo "Verify the md5sums: " +md5sum pmd-dist/target/pmd-*-${RELEASE_VERSION}.zip target/pmd-doc-${RELEASE_VERSION}.zip + +echo +echo "and make the new binary pmd zip file the default download for all platforms." +echo +echo "Press enter to continue..." +read +) + +echo +echo "Submit news to SF on page. You can use" +echo "the following template:" +echo +cat <" +echo +echo "Press enter to continue..." +read + +echo "Last step - next development version:" +echo "* Move version/release info from **src/site/markdown/overview/changelog.md** to **src/site/markdown/overview/changelog-old.md**." +echo "* Update version/release info in **src/site/markdown/overview/changelog.md**." +echo "* Update pmd-{java8,ui}/pom.xml - the version is probably wrong - set it to the parent's=next development version: ${DEVELOPMENT_VERSION}." +echo +cat <" +echo +echo " * Set the title: PMD ${RELEASE_VERSION} ($(date -u +%d-%B-%Y))" +echo " * copy/paste the changelog.md" +echo " * Upload the binary zip file" +echo " * Upload the doc zip file" +echo +echo "Press enter to continue..." +read + + +echo +echo "------------------------------------------" +echo "Done." +echo "------------------------------------------" +echo + +