Skip to content

Commit b67c153

Browse files
Fixing release script bugs, making formal releases manual (#1590)
* Not auto-releasing after close (so that releases can be staged) * Splitting release.sh into stage_release.sh and finalize_release.sh * Stripping the qualifier from the SITE_VERSION for generating the gh-pages site * Fixing deploy.sh (the input checking was wrong) * Not running any tests in deploy.sh (they are already run in other contexts before this point) * Updating RELEASING.md with the new process
1 parent c230c0f commit b67c153

File tree

7 files changed

+46
-59
lines changed

7 files changed

+46
-59
lines changed

RELEASING.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
### Overview
22

3-
Most of the release process is handled by the `after_success.sh` script, triggered after Travis CI successfully completes a non-PR build. A new artifact will be released to Maven Central Repository via Travis CI when "-SNAPSHOT" is not included in the version (as listed in the base directory's `pom.xml`). The website and README files will also be updated automatically in this case. When "-SNAPSHOT" is included in the version, Travis only updates the artifact in the snapshot repository.
3+
The release process for SNAPSHOT versions is handled by the `after_success.sh` script, triggered after Travis CI successfully completes a non-PR build. A new SNAPSHOT artifact will be released to the snapshot repository as part of this script.
44

55
### To push a release version
66

7-
1. Run `utilities/update_pom_version.sh` from the repository's base directory.
8-
This script takes an optional argument denoting the new version. By default, if the current version is X.Y.Z-SNAPSHOT, the script will update the version in all the pom.xml files to X.Y.Z. If desired, another version can be supplied via command line argument instead.
7+
1. Make sure the team agrees that it is time to release. Verify that all unit and integration tests for the last commit have passed.
98

10-
2. Create a PR to update the pom.xml version. If releasing a new client library, this PR should also update javadoc grouping in the base directory's [pom.xml](./pom.xml).
11-
PRs that don't release new modules should look something like [#225](https://github.com/GoogleCloudPlatform/google-cloud-java/pull/225). PRs that do release a new module should also add the appropriate packages to the javadoc groups "SPI" and "Test helpers", as shown in [#802](https://github.com/GoogleCloudPlatform/google-cloud-java/pull/802) for `google-cloud-dns`. After this PR is merged into GoogleCloudPlatform/google-cloud-java, Travis CI will push a new website to GoogleCloudPlatform/gh-pages, push a new artifact to the Maven Central Repository, and update versions in the README files. Do not merge in any non-release-related pull requests between the start of step 2 and the end of step 6. Between these steps, the project version is a non-snapshot version, so any commits to the master branch will cause Travis to spend extra resources attempting to redeploy artifacts.
9+
2. Run `utilities/update_pom_version.sh` from the repository's base directory.
10+
This script takes an optional argument denoting the new version. By default, if the current version is X.Y.Z-SNAPSHOT, the script will update the version in all the pom.xml files to X.Y.Z. If desired, another version can be supplied via command line argument instead. Commit this version locally:
1211

13-
3. Before moving on, verify that the artifacts have successfully been pushed to the Maven Central Repository. Open Travis CI, click the ["Build History" tab](https://travis-ci.org/GoogleCloudPlatform/google-cloud-java/builds), and open the second build's logs for Step 2's PR. Be sure that you are not opening the "Pull Request" build logs. When the build finishes, scroll to the end of the log and verify that the artifacts were successfully staged and deployed. Search for `google-cloud` on the [Sonatype website](https://oss.sonatype.org/#nexus-search;quick~google-cloud) and check the latest version number. In rare cases (when the Maven plugin that determines the version of the repository fails), the artifacts may not be deployed even if the version in the pom.xml files doesn't contain `SNAPSHOT`. If the artifacts weren't deployed due to invalid version parsing or a flaky test, rerun the build.
12+
```
13+
git commit -m "Release [VERSION HERE]"
14+
```
15+
16+
3. Run `utilities/stage_release.sh`.
17+
This script builds and stages the release artifact on the Maven Central Repository, updates the README.md files with the release version + commits them locally, and finally generates a new site version for the gh-pages branch under a temporary directory named `tmp_gh-pages`. If you haven't run the release process before, it's worth verifying everything; check the staged release on the Sonatype website, and verify that the local commits have the right version updates.
18+
19+
4. Run `utilities/finalize_release.sh`.
20+
This script will release the staged artifact on the Maven Central Repository and push the README.md and gh-pages updates to github.
1421

15-
4. Publish a release on Github manually.
22+
5. Publish a release on Github manually.
1623
Go to the [releases page](https://github.com/GoogleCloudPlatform/google-cloud-java/releases) and open the appropriate release draft. Make sure the "Tag Version" is `vX.Y.Z` and the "Release Title" is `X.Y.Z`, where `X.Y.Z` is the release version as listed in the `pom.xml` files. The draft should already have all changes that impact users since the previous release. To double check this, you can use the `git log` command and look through the merged master branch pull requests. Here is an example of the log command to get non-merge commits between v0.0.12 and v0.1.0:
1724

1825
```
@@ -21,12 +28,12 @@ Go to the [releases page](https://github.com/GoogleCloudPlatform/google-cloud-ja
2128

2229
Ensure that the format is consistent with previous releases (for an example, see the [0.1.0 release](https://github.com/GoogleCloudPlatform/google-cloud-java/releases/tag/v0.1.0)). After adding any missing updates and reformatting as necessary, publish the draft. Finally, create a new draft for the next release.
2330

24-
5. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
31+
6. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
2532
As mentioned before, there is an optional version argument. By default, the script will update the version from "X.Y.Z" to "X.Y.Z+1-SNAPSHOT". Suppose a different version is desired, for example X+1.0.0-SNAPSHOT. Then the appropriate command to run would be `utilities/update_pom_version.sh X+1.0.0-SNAPSHOT`.
2633

27-
6. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/google-cloud-java/pull/227).
34+
7. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/google-cloud-java/pull/227).
2835

29-
7. Be sure to update Google Cloud Platform docs, [java-docs-samples](https://github.com/GoogleCloudPlatform/java-docs-samples) code/docs, and [getting-started-java](https://github.com/GoogleCloudPlatform/getting-started-java) code/docs. See directions [here](https://docs.google.com/a/google.com/document/d/1SS3xNn2v0qW7EadGUPBUAPIQAH5VY6WSFmT17ZjjUVE/).
36+
8. Be sure to update Google Cloud Platform docs, [java-docs-samples](https://github.com/GoogleCloudPlatform/java-docs-samples) code/docs, and [getting-started-java](https://github.com/GoogleCloudPlatform/getting-started-java) code/docs. See directions [here](https://docs.google.com/a/google.com/document/d/1SS3xNn2v0qW7EadGUPBUAPIQAH5VY6WSFmT17ZjjUVE/).
3037

3138
### To push a snapshot version
3239

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
<configuration>
272272
<serverId>sonatype-nexus-staging</serverId>
273273
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
274-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
274+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
275275
</configuration>
276276
</plugin>
277277
<plugin>

utilities/after_success.sh

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,8 @@ if [ "${TRAVIS_JDK_VERSION}" == "oraclejdk7" ]; then
1717
echo "Could not determine the version, so we're exiting."
1818
exit 1
1919
fi
20-
if [ "${SITE_VERSION##*-}" != "SNAPSHOT" ]; then
21-
# Deploy Maven artifacts (if they don't exist yet) and update artifact version in READMEs.
22-
URL=https://oss.sonatype.org/content/repositories/releases/com/google/cloud/google-cloud/$SITE_VERSION/
23-
if curl --output /dev/null --silent --head --fail "$URL"; then
24-
echo "Not deploying artifacts because it seems like they already exist."
25-
echo "Existence was checked using the url $URL"
26-
else
27-
mvn clean deploy --quiet -Djava.util.logging.config.file=logging.properties -DskipITs --settings ~/.m2/settings.xml -P sign-deploy,release
28-
fi
29-
utilities/update_docs_version.sh
3020

31-
# Create website
32-
git config --global user.name "travis-ci"
33-
git config --global user.email "travis@travis-ci.org"
34-
git clone --branch gh-pages --single-branch https://github.com/GoogleCloudPlatform/google-cloud-java/ tmp_gh-pages
35-
mkdir -p tmp_gh-pages/$SITE_VERSION
36-
mvn site -DskipTests=true -Djava.util.logging.config.file=logging.properties
37-
mvn site:stage --quiet -Djava.util.logging.config.file=logging.properties -DtopSiteURL=http://googlecloudplatform.github.io/google-cloud-java/site/${SITE_VERSION}/
38-
cd tmp_gh-pages
39-
cp -r ../target/staging/$SITE_VERSION/* $SITE_VERSION/
40-
sed -i "s/{{SITE_VERSION}}/$SITE_VERSION/g" ${SITE_VERSION}/index.html # Update "Quickstart with Maven" to reflect version change
41-
git add $SITE_VERSION
42-
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
43-
git add index.html
44-
echo "<html><head><script>window.location.replace('/google-cloud-java/${SITE_VERSION}/apidocs' + location.search)</script></head><body></body></html>" > apidocs/index.html
45-
git add apidocs/index.html
46-
git commit --quiet -m "Added a new site for version $SITE_VERSION and updated the root directory's redirect. [ci skip]"
47-
git config --global push.default simple
48-
git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/google-cloud-java.git" > /dev/null 2>&1
49-
else
50-
mvn clean deploy --quiet -Djava.util.logging.config.file=logging.properties -DskipTests=true -Dgpg.skip=true --settings ~/.m2/settings.xml -P release
21+
mvn clean deploy --quiet -Djava.util.logging.config.file=logging.properties -DskipTests=true -Dgpg.skip=true --settings ~/.m2/settings.xml -P release
5122
fi
5223
else
5324
echo "Not deploying artifacts. This is only done with non-pull-request commits to master branch with Oracle Java 7 builds."

utilities/create_site.sh

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,31 @@
33
set -e
44

55
SITE_VERSION=$1
6+
SITE_VERSION_BASE=$(sed -r 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/' <<< "$SITE_VERSION")
67

7-
echo "Creating docs for google-cloud-java $SITE_VERSION"
8+
echo "Creating site for google-cloud-java $SITE_VERSION_BASE"
89

9-
if [ -z "$SITE_VERSION" ]; then
10+
if [ -z "$SITE_VERSION_BASE" ]; then
1011
echo "First arg (version) not provided, so we're exiting."
1112
exit 1
1213
fi
1314

1415
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+
mkdir -p tmp_gh-pages/$SITE_VERSION_BASE
1617
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+
mvn site:stage --quiet -Djava.util.logging.config.file=logging.properties -DtopSiteURL=http://googlecloudplatform.github.io/google-cloud-java/site/${SITE_VERSION_BASE}/
1819
cd tmp_gh-pages
1920

20-
for dir in ../target/staging/${SITE_VERSION}*
21+
for dir in ../target/staging/${SITE_VERSION_BASE}*
2122
do
22-
cp -r ${dir}/* $SITE_VERSION/
23+
cp -r ${dir}/* $SITE_VERSION_BASE/
2324
done
2425

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
26+
sed -i "s/{{SITE_VERSION}}/$SITE_VERSION/g" ${SITE_VERSION_BASE}/index.html # Update "Quickstart with Maven" to reflect version change
27+
git add $SITE_VERSION_BASE
28+
echo "<html><head><meta http-equiv=\"refresh\" content=\"0; URL='http://GoogleCloudPlatform.github.io/google-cloud-java/${SITE_VERSION_BASE}/index.html'\" /></head><body></body></html>" > index.html
2829
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+
echo "<html><head><script>window.location.replace('/google-cloud-java/${SITE_VERSION_BASE}/apidocs' + location.search)</script></head><body></body></html>" > apidocs/index.html
3031
git add apidocs/index.html
3132

3233
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
SITE_VERSION=$1
66

7-
if [ -n $SITE_VERSION ]; then
7+
if [ -z $SITE_VERSION ]; then
88
echo "First arg (version) not provided, so we're exiting."
99
exit 1
1010
fi
@@ -20,6 +20,6 @@ else
2020
echo "Existence was checked using the url $URL"
2121
else
2222
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
23+
mvn clean deploy --quiet -Djava.util.logging.config.file=logging.properties -DskipTests=true --settings ~/.m2/settings.xml -P release
2424
fi
2525
fi

utilities/finalize_release.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
mvn nexus-staging:release
6+
7+
# Push the version and README updates
8+
git push
9+
10+
# Push the gh-pages updates
11+
cd tmp_gh-pages
12+
git push
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
SITE_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)')
66
echo "Used the maven-help-plugin to determine that the version is $SITE_VERSION"
7-
if [ "$SITE_VERSION" == "" ]; then
7+
if [ -z "$SITE_VERSION" ]; then
88
echo "Could not determine the version, so we're exiting."
99
exit 1
1010
fi
@@ -19,7 +19,7 @@ if [ "${SITE_VERSION##*-}" != "SNAPSHOT" ]; then
1919
git commit --quiet -m "Updating version in README files. [ci skip]"
2020

2121
# Create website
22-
./utilities/create_site.sh
22+
./utilities/create_site.sh "$SITE_VERSION"
2323

2424
cd tmp_gh-pages
2525
git commit --quiet -m "Added a new site for version $SITE_VERSION and updated the root directory's redirect. [ci skip]"

0 commit comments

Comments
 (0)