Skip to content

Commit ce75004

Browse files
New manual version updating and releasing scripts
Note: These scripts are more modular variants of the existing scripts which are run by Travis; in a later commit, the Travis scripts should be updated to only release SNAPSHOT versions and not non-snapshot versions.
1 parent 6ef3ec8 commit ce75004

5 files changed

Lines changed: 140 additions & 5 deletions

File tree

utilities/create_site.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SITE_VERSION=$1
6+
7+
echo "Creating docs for google-cloud-java $SITE_VERSION"
8+
9+
if [ -z "$SITE_VERSION" ]; then
10+
echo "First arg (version) not provided, so we're exiting."
11+
exit 1
12+
fi
13+
14+
git clone --branch gh-pages --single-branch https://github.com/GoogleCloudPlatform/google-cloud-java/ tmp_gh-pages
15+
mkdir -p tmp_gh-pages/$SITE_VERSION
16+
mvn site -DskipTests=true -Djava.util.logging.config.file=logging.properties
17+
mvn site:stage --quiet -Djava.util.logging.config.file=logging.properties -DtopSiteURL=http://googlecloudplatform.github.io/google-cloud-java/site/${SITE_VERSION}/
18+
cd tmp_gh-pages
19+
20+
for dir in ../target/staging/${SITE_VERSION}*
21+
do
22+
cp -r ${dir}/* $SITE_VERSION/
23+
done
24+
25+
sed -i "s/{{SITE_VERSION}}/$SITE_VERSION/g" ${SITE_VERSION}/index.html # Update "Quickstart with Maven" to reflect version change
26+
git add $SITE_VERSION
27+
echo "<html><head><meta http-equiv=\"refresh\" content=\"0; URL='http://GoogleCloudPlatform.github.io/google-cloud-java/${SITE_VERSION}/index.html'\" /></head><body></body></html>" > index.html
28+
git add index.html
29+
echo "<html><head><script>window.location.replace('/google-cloud-java/${SITE_VERSION}/apidocs' + location.search)</script></head><body></body></html>" > apidocs/index.html
30+
git add apidocs/index.html
31+
32+
echo "Site generated under tmp_gh-pages/. The changes must be committed from that directory."
33+
echo "Recommended commands: (this will push the new site to the gh-pages branch)"
34+
echo " cd tmp_gh-pages"
35+
echo " git commit -m \"Added a new site for version $SITE_VERSION and updated the root directory's redirect. [ci skip]\""
36+
echo " git push"

utilities/deploy.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SITE_VERSION=$1
6+
7+
if [ -n $SITE_VERSION ]; then
8+
echo "First arg (version) not provided, so we're exiting."
9+
exit 1
10+
fi
11+
12+
if [ "${SITE_VERSION##*-}" == "SNAPSHOT" ]; then
13+
echo "Deploying Snapshot artifacts..."
14+
mvn clean deploy --quiet -Djava.util.logging.config.file=logging.properties -DskipTests=true -Dgpg.skip=true --settings ~/.m2/settings.xml -P release
15+
else
16+
# Deploy Maven artifacts (if they don't exist yet) and update artifact version in READMEs.
17+
URL=https://oss.sonatype.org/content/repositories/releases/com/google/cloud/google-cloud/$SITE_VERSION/
18+
if curl --output /dev/null --silent --head --fail "$URL"; then
19+
echo "Not deploying artifacts because it seems like they already exist."
20+
echo "Existence was checked using the url $URL"
21+
else
22+
echo "Deploying Release artifacts..."
23+
mvn clean deploy --quiet -Djava.util.logging.config.file=logging.properties -DskipITs --settings ~/.m2/settings.xml -P sign-deploy,release
24+
fi
25+
fi

utilities/release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SITE_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)')
6+
echo "Used the maven-help-plugin to determine that the version is $SITE_VERSION"
7+
if [ "$SITE_VERSION" == "" ]; then
8+
echo "Could not determine the version, so we're exiting."
9+
exit 1
10+
fi
11+
12+
# Deploy the build artifacts to Sonatype
13+
./utilities/deploy.sh "$SITE_VERSION"
14+
15+
if [ "${SITE_VERSION##*-}" != "SNAPSHOT" ]; then
16+
# Update the versions on the docs
17+
./utilities/update_readme_version.sh
18+
19+
git commit --quiet -m "Updating version in README files. [ci skip]"
20+
21+
# Create website
22+
./utilities/create_site.sh
23+
24+
cd tmp_gh-pages
25+
git commit --quiet -m "Added a new site for version $SITE_VERSION and updated the root directory's redirect. [ci skip]"
26+
fi

utilities/update_pom_version.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,37 @@
88
# x.y.z+1-SNAPSHOT if the current version is x.y.z OR to x.y.z if the
99
# current version is x.y.z-SNAPSHOT.
1010

11+
set -e
12+
1113
# Get the previous maven project version.
1214
CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)')
15+
CURRENT_VERSION_BASE=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
16+
1317
# Get list of directories for which pom.xml must be updated
1418
module_folders=($(find . -maxdepth 2 -type d | sed -E -n "/^\.\/(google-cloud-contrib\/)?google-cloud(-[a-z]+)+$/p") . ./google-cloud)
19+
20+
CURRENT_SNAPSHOT=""
21+
if [ "${CURRENT_VERSION##*-}" == "SNAPSHOT" ]; then
22+
CURRENT_SNAPSHOT="-SNAPSHOT"
23+
fi
24+
25+
NEW_SNAPSHOT=""
1526
if [ $# -eq 1 ]; then
16-
NEW_VERSION=$1
27+
NEW_VERSION_BASE=$1
28+
if [ "${NEW_VERSION_BASE##*-}" == "SNAPSHOT" ]; then
29+
NEW_SNAPSHOT="-SNAPSHOT"
30+
fi
1731
elif [ "${CURRENT_VERSION##*-}" != "SNAPSHOT" ]; then
18-
NEW_VERSION="${CURRENT_VERSION%.*}.$((${CURRENT_VERSION##*.}+1))-SNAPSHOT"
32+
NEW_VERSION_BASE="${CURRENT_VERSION%.*}.$((${CURRENT_VERSION##*.}+1))"
33+
NEW_SNAPSHOT="-SNAPSHOT"
1934
else
20-
NEW_VERSION=${CURRENT_VERSION%%-*}
35+
NEW_VERSION_BASE=${CURRENT_VERSION%%-*}
2136
fi
2237

23-
echo "Changing version from $CURRENT_VERSION to $NEW_VERSION in pom.xml files"
38+
echo "Changing version from ${CURRENT_VERSION_BASE}-*${CURRENT_SNAPSHOT} to ${NEW_VERSION_BASE}-*${NEW_SNAPSHOT} in pom.xml files"
2439
for item in ${module_folders[*]}
2540
do
26-
sed -i "0,/<version>$CURRENT_VERSION/s/<version>$CURRENT_VERSION/<version>$NEW_VERSION/" ${item}/pom.xml
41+
sed -ri "0,/<version>$CURRENT_VERSION_BASE/s/<version>${CURRENT_VERSION_BASE}(-[a-z]+)?[^<]*/<version>${NEW_VERSION_BASE}\1${NEW_SNAPSHOT}/" ${item}/pom.xml
2742
done
43+
sed -ri "0,/<core.version>$CURRENT_VERSION_BASE/s/<core.version>${CURRENT_VERSION_BASE}(-[a-z]+)?[^<]*/<core.version>${NEW_VERSION_BASE}\1${NEW_SNAPSHOT}/" pom.xml
44+
sed -ri "0,/<beta.version>$CURRENT_VERSION_BASE/s/<beta.version>${CURRENT_VERSION_BASE}(-[a-z]+)?[^<]*/<beta.version>${NEW_VERSION_BASE}\1${NEW_SNAPSHOT}/" pom.xml

utilities/update_readme_version.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
set -e
8+
9+
# Get the current maven project version.
10+
RELEASED_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
11+
12+
if [ "${RELEASED_VERSION##*-}" != "SNAPSHOT" ]; then
13+
echo "Changing version to $RELEASED_VERSION in README files"
14+
# Get list of directories for which README.md must be updated
15+
module_folders=($(find . -maxdepth 2 -type d | sed -E -n "/^\.\/(google-cloud-contrib\/)?google-cloud(-[a-z]+)+$/p") . ./google-cloud)
16+
readmes=""
17+
for item in ${module_folders[*]}
18+
do
19+
if [ -f ${item}/README.md ]; then
20+
sed -ri "s/<version>[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?<\/version>/<version>${RELEASED_VERSION}\1<\/version>/g" ${item}/README.md
21+
sed -ri "s/:[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?'/:${RELEASED_VERSION}\1'/g" ${item}/README.md
22+
sed -ri "s/\"[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?\"/\"${RELEASED_VERSION}\1\"/g" ${item}/README.md
23+
readmes="$readmes ${item}/README.md"
24+
fi
25+
done
26+
NEW_VERSION=${RELEASED_VERSION%.*}.$((${RELEASED_VERSION##*.}+1))-alpha-SNAPSHOT
27+
echo "Changing version to $NEW_VERSION in google-cloud-nio-example README"
28+
sed -ri "s/google-cloud-nio-[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?-SNAPSHOT/google-cloud-nio-$NEW_VERSION/g" google-cloud-contrib/google-cloud-nio-examples/README.md
29+
sed -ri "s/google-cloud-nio-examples-[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?-SNAPSHOT/google-cloud-nio-examples-$NEW_VERSION/g" google-cloud-contrib/google-cloud-nio-examples/README.md
30+
git add $readmes
31+
fi

0 commit comments

Comments
 (0)