Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to update version in pom.xml and README docs #154

Merged
merged 1 commit into from
Sep 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions utilities/after_success.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions utilities/update_docs_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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 <version>#.#.#</version> with <version>7.8.9</version> 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) .)
for item in ${module_folders[*]}
do
sed -ri "s/<version>[0-9]+\.[0-9]+\.[0-9]+<\/version>/<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
28 changes: 28 additions & 0 deletions utilities/update_pom_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/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): new version number for pom.xml files
# Providing no argument defaults to incrementing revision number to
# x.y.z+1-SNAPSHOT if the current version is x.y.z OR to x.y.z if the
# current version is x.y.z-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) .)

if [ $# -eq 1 ]; then
NEW_VERSION=$1
elif [ "${CURRENT_VERSION##*-}" != "SNAPSHOT" ]; then
NEW_VERSION="${CURRENT_VERSION%.*}.$((${CURRENT_VERSION##*.}+1))-SNAPSHOT"
else
NEW_VERSION=${CURRENT_VERSION%%-*}
fi

echo "Changing version from $CURRENT_VERSION to $NEW_VERSION in pom.xml files"
for item in ${module_folders[*]}
do
sed -i "0,/<version>$CURRENT_VERSION/s/<version>$CURRENT_VERSION/<version>$NEW_VERSION/" ${item}/pom.xml
done