From 72f558d887c1962623409d155c84f5a6737a6df7 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 1 Sep 2015 15:29:19 -0700 Subject: [PATCH] New scripts to update version in pom.xml and README docs. --- utilities/after_success.sh | 4 ++++ utilities/update_docs_version.sh | 25 ++++++++++++++++++++++++ utilities/update_pom_version.sh | 33 ++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 utilities/update_docs_version.sh create mode 100755 utilities/update_pom_version.sh diff --git a/utilities/after_success.sh b/utilities/after_success.sh index 46ac33dce9de..0511f6f441e5 100755 --- a/utilities/after_success.sh +++ b/utilities/after_success.sh @@ -27,6 +27,10 @@ if [ "${TRAVIS_JDK_VERSION}" == "oraclejdk7" -a "${TRAVIS_BRANCH}" == "master" - git commit -m "Added a new site for version $SITE_VERSION and updated the root directory's redirect." git config --global push.default simple git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/gcloud-java.git" > /dev/null 2>&1 + + # Update versions README and pom.xml in master branch + cd .. + utilities/update_docs_version.sh else mvn deploy -DskipTests=true -Dgpg.skip=true --settings target/travis/settings.xml fi diff --git a/utilities/update_docs_version.sh b/utilities/update_docs_version.sh new file mode 100755 index 000000000000..f242a281c7f7 --- /dev/null +++ b/utilities/update_docs_version.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# This script updates the READMEs with the latest non-SNAPSHOT version number. +# Example: Suppose that before running this script, the pom.xml reads 7.8.9. This script will replace +# all occurrences of #.#.# with 7.8.9 in the README files. + +# Get the current maven project version. +RELEASED_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)') + +if [ "${RELEASED_VERSION##*-}" != "SNAPSHOT" ]; then + echo "Changing version to $RELEASED_VERSION in README files" + # Get list of directories for which README.md must be updated + module_folders=($(find . -maxdepth 1 -name 'gcloud-java*' -type d)) + module_folders+=(.) + for item in ${module_folders[*]} + do + sed -ri "s/[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*<\/version>/${RELEASED_VERSION}<\/version>/g" ${item}/README.md + done + + git add README.md */README.md + git config --global user.name "travis-ci" + git config --global user.email "travis@travis-ci.org" + git commit -m "Updating version in README files." + git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/gcloud-java.git" HEAD:master > /dev/null 2>&1 +fi diff --git a/utilities/update_pom_version.sh b/utilities/update_pom_version.sh new file mode 100755 index 000000000000..fbdca7a228b0 --- /dev/null +++ b/utilities/update_pom_version.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# This script updates the pom.xml files to the next version number. +# This script is meant to be run manually (not by Travis) + +# Argument (optional): +# $1: new version number for pom.xml files (do not include -SNAPSHOT, that is done automatically). +# Providing no argument defaults to incrementing revision number from x.y.z to x.y.z+1-SNAPSHOT + +# Get the previous maven project version. +CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)') +# Get list of directories for which pom.xml must be updated +module_folders=($(find . -maxdepth 1 -name 'gcloud-java*' -type d)) +module_folders+=(.) + +if [ "${CURRENT_VERSION##*-}" != "SNAPSHOT" ]; then + # Update x.y.z to x.y.z+1-SNAPSHOT by default, or to a.b.c-SNAPSHOT, where a.b.c is given by user. + DEFAULT_UPDATE="${CURRENT_VERSION%.*}.$((${CURRENT_VERSION##*.}+1))" + NEW_SNAPSHOT_VERSION=${1:-$DEFAULT_UPDATE}-SNAPSHOT + echo "Changing version from $CURRENT_VERSION to $NEW_SNAPSHOT_VERSION in pom.xml files" + for item in ${module_folders[*]} + do + sed -i "0,/$CURRENT_VERSION/s/$CURRENT_VERSION/$NEW_SNAPSHOT_VERSION/" ${item}/pom.xml + done +else + # Update from x.y.z-SNAPSHOT to x.y.z + NEW_RELEASE_VERSION=${CURRENT_VERSION%%-*} + echo "Changing version from $CURRENT_VERSION to $NEW_RELEASE_VERSION in pom.xml files" + for item in ${module_folders[*]} + do + sed -i "0,/$CURRENT_VERSION/s/$CURRENT_VERSION/$NEW_RELEASE_VERSION/" ${item}/pom.xml + done +fi