forked from googleapis/google-cloud-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_docs_version.sh
More file actions
executable file
·26 lines (22 loc) · 1.41 KB
/
update_docs_version.sh
File metadata and controls
executable file
·26 lines (22 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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
sed -ri "s/:[0-9]+\.[0-9]+\.[0-9]+'/:${RELEASED_VERSION}'/g" ${item}/README.md
sed -ri "s/\"[0-9]+\.[0-9]+\.[0-9]+\"/\"${RELEASED_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. [ci skip]"
git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/gcloud-java.git" HEAD:master > /dev/null 2>&1
fi