Skip to content

Commit 72f558d

Browse files
author
Ajay Kannan
committed
New scripts to update version in pom.xml and README docs.
1 parent 9d3b525 commit 72f558d

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

utilities/after_success.sh

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ if [ "${TRAVIS_JDK_VERSION}" == "oraclejdk7" -a "${TRAVIS_BRANCH}" == "master" -
2727
git commit -m "Added a new site for version $SITE_VERSION and updated the root directory's redirect."
2828
git config --global push.default simple
2929
git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/gcloud-java.git" > /dev/null 2>&1
30+
31+
# Update versions README and pom.xml in master branch
32+
cd ..
33+
utilities/update_docs_version.sh
3034
else
3135
mvn deploy -DskipTests=true -Dgpg.skip=true --settings target/travis/settings.xml
3236
fi

utilities/update_docs_version.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# This script updates the READMEs with the latest non-SNAPSHOT version number.
4+
# Example: Suppose that before running this script, the pom.xml reads 7.8.9. This script will replace
5+
# all occurrences of <version>#.#.#</version> with <version>7.8.9</version> in the README files.
6+
7+
# Get the current maven project version.
8+
RELEASED_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)')
9+
10+
if [ "${RELEASED_VERSION##*-}" != "SNAPSHOT" ]; then
11+
echo "Changing version to $RELEASED_VERSION in README files"
12+
# Get list of directories for which README.md must be updated
13+
module_folders=($(find . -maxdepth 1 -name 'gcloud-java*' -type d))
14+
module_folders+=(.)
15+
for item in ${module_folders[*]}
16+
do
17+
sed -ri "s/<version>[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*<\/version>/<version>${RELEASED_VERSION}<\/version>/g" ${item}/README.md
18+
done
19+
20+
git add README.md */README.md
21+
git config --global user.name "travis-ci"
22+
git config --global user.email "[email protected]"
23+
git commit -m "Updating version in README files."
24+
git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/gcloud-java.git" HEAD:master > /dev/null 2>&1
25+
fi

utilities/update_pom_version.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# This script updates the pom.xml files to the next version number.
4+
# This script is meant to be run manually (not by Travis)
5+
6+
# Argument (optional):
7+
# $1: new version number for pom.xml files (do not include -SNAPSHOT, that is done automatically).
8+
# Providing no argument defaults to incrementing revision number from x.y.z to x.y.z+1-SNAPSHOT
9+
10+
# Get the previous maven project version.
11+
CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)')
12+
# Get list of directories for which pom.xml must be updated
13+
module_folders=($(find . -maxdepth 1 -name 'gcloud-java*' -type d))
14+
module_folders+=(.)
15+
16+
if [ "${CURRENT_VERSION##*-}" != "SNAPSHOT" ]; then
17+
# 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.
18+
DEFAULT_UPDATE="${CURRENT_VERSION%.*}.$((${CURRENT_VERSION##*.}+1))"
19+
NEW_SNAPSHOT_VERSION=${1:-$DEFAULT_UPDATE}-SNAPSHOT
20+
echo "Changing version from $CURRENT_VERSION to $NEW_SNAPSHOT_VERSION in pom.xml files"
21+
for item in ${module_folders[*]}
22+
do
23+
sed -i "0,/<version>$CURRENT_VERSION/s/<version>$CURRENT_VERSION/<version>$NEW_SNAPSHOT_VERSION/" ${item}/pom.xml
24+
done
25+
else
26+
# Update from x.y.z-SNAPSHOT to x.y.z
27+
NEW_RELEASE_VERSION=${CURRENT_VERSION%%-*}
28+
echo "Changing version from $CURRENT_VERSION to $NEW_RELEASE_VERSION in pom.xml files"
29+
for item in ${module_folders[*]}
30+
do
31+
sed -i "0,/<version>$CURRENT_VERSION/s/<version>$CURRENT_VERSION/<version>$NEW_RELEASE_VERSION/" ${item}/pom.xml
32+
done
33+
fi

0 commit comments

Comments
 (0)