blob: 8f1f3acd7502721503aede0f2bba6f1b6eea4188 [file] [log] [blame] [view]
nmittler483738e2015-06-08 14:32:37 -07001How to Create a Release of GRPC Java (for Maintainers Only)
2===============================================================
3
4Build Environments
5------------------
6We deploy GRPC to Maven Central under the following systems:
7- Ubuntu 14.04 with Docker 1.6.1 that runs CentOS 6.6
8- Windows 7 64-bit with MSYS2 with mingw32 and mingw64
9- Mac OS X 10.9.5
10
11Other systems may also work, but we haven't verified them.
12
13Prerequisites
14-------------
15
16### Setup OSSRH and Signing
17
18If you haven't deployed artifacts to Maven Central before, you need to setup
19your OSSRH (OSS Repository Hosting) account and signing keys.
20- Follow the instructions on [this
21 page](http://central.sonatype.org/pages/ossrh-guide.html) to set up an
22 account with OSSRH.
Carl Mastrangelo7a6b1662015-08-12 13:52:45 -070023 - You only need to create the account, not set up a new project
24 - Contact a gRPC maintainer to add your account after you have created it.
nmittler483738e2015-06-08 14:32:37 -070025- (For release deployment only) Install GnuPG and [generate your key
26 pair](https://www.gnupg.org/documentation/howtos.html). You'll also
27 need to [publish your public key](https://www.gnupg.org/gph/en/manual.html#AEN464)
28 to make it visible to the Sonatype servers
29 (e.g. `gpg --keyserver pgp.mit.edu --send-key <key ID>`).
30- Put your GnuPG key password and OSSRH account information in
31 `<your-home-directory>/.gradle/gradle.properties`.
32
33```
34# You need the signing properties only if you are making release deployment
35signing.keyId=<8-character-public-key-id>
36signing.password=<key-password>
37signing.secretKeyRingFile=<your-home-directory>/.gnupg/secring.gpg
38
39ossrhUsername=<ossrh-username>
40ossrhPassword=<ossrh-password>
41checkstyle.ignoreFailures=false
42```
43
44### Build Protobuf
45Protobuf libraries are needed for compiling the GRPC codegen. Despite that you
46may have installed Protobuf on your system, you may want to build Protobuf
47separately and install it under your personal directory, because
48
491. The Protobuf version installed on your system may be different from what
50 GRPC requires. You may not want to pollute your system installation.
512. We will deploy both 32-bit and 64-bit versions of the codegen, thus require
52 both variants of Protobuf libraries. You don't want to mix them in your
53 system paths.
54
55Please see the [Main Readme](README.md) for details on building protobuf.
56
57Tagging the Release
58----------------------
Eric Andersonb8245652016-02-17 11:34:50 -080059The first step in the release process is to create a release branch, bump
60versions, and create a tag for the release. Our release branches follow the naming
nmittler483738e2015-06-08 14:32:37 -070061convention of `v<major>.<minor>.x`, while the tags include the patch version
62`v<major>.<minor>.<patch>`. For example, the same branch `v0.7.x`
63would be used to create all `v0.7` tags (e.g. `v0.7.0`, `v0.7.1`).
64
Eric Andersonb8245652016-02-17 11:34:50 -0800651. Create the release branch and push it to GitHub:
nmittler483738e2015-06-08 14:32:37 -070066
67 ```bash
Eric Andersonb8245652016-02-17 11:34:50 -080068 $ MAJOR=0 MINOR=7 PATCH=0 # Set appropriately for new release
69 $ git checkout -b v$MAJOR.$MINOR.x master
70 $ git push upstream v$MAJOR.$MINOR.x
nmittler483738e2015-06-08 14:32:37 -070071 ```
Eric Anderson554287a2016-06-16 10:12:41 -0700722. For `master`, change root build files to the next minor snapshot (e.g.
Eric Andersonb8245652016-02-17 11:34:50 -080073 ``0.8.0-SNAPSHOT``).
nmittler483738e2015-06-08 14:32:37 -070074
75 ```bash
Eric Andersonb8245652016-02-17 11:34:50 -080076 $ git checkout -b bump-version master
77 # Change version to next minor (and keep -SNAPSHOT)
78 $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \
Eric Anderson13f01222016-03-15 12:53:44 -070079 build.gradle android-interop-testing/app/build.gradle \
Eric Andersond7bf67e2016-06-24 18:18:06 -070080 examples/build.gradle examples/pom.xml \
Naveen Reddy Chedeti28609592016-07-28 08:48:27 -070081 examples/android/app/build.gradle examples/thrift/build.gradle
Eric Anderson7b26a322016-07-01 11:59:21 -070082 $ ./gradlew build
Eric Andersonb8245652016-02-17 11:34:50 -080083 $ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle"
nmittler483738e2015-06-08 14:32:37 -070084 ```
Eric Andersonb8245652016-02-17 11:34:50 -0800853. Go through PR review and push the master branch to GitHub:
nmittler483738e2015-06-08 14:32:37 -070086
87 ```bash
Eric Andersonb8245652016-02-17 11:34:50 -080088 $ git checkout master
89 $ git merge --ff-only bump-version
90 $ git push upstream master
nmittler483738e2015-06-08 14:32:37 -070091 ```
Eric Andersonf25f55a2016-08-04 13:51:20 -0700924. For vMajor.Minor.x branch, change `README.md` to refer to the next release
93 version. _Also_ update the version numbers for protoc if the protobuf library
94 version was updated since the last release.
nmittler483738e2015-06-08 14:32:37 -070095
96 ```bash
Eric Andersonb8245652016-02-17 11:34:50 -080097 $ git checkout -b release v$MAJOR.$MINOR.x
Eric Andersonf25f55a2016-08-04 13:51:20 -070098 # Bump documented versions. Don't forget protobuf version
99 $ ${EDITOR:-nano -w} README.md
100 $ git commit -a -m "Update README to reference $MAJOR.$MINOR.$PATCH"
101 ```
1025. Change root build files to remove "-SNAPSHOT" for the next release version
103 (e.g. `0.7.0`). Commit the result and make a tag:
104
105 ```bash
Eric Andersonb8245652016-02-17 11:34:50 -0800106 # Change version to remove -SNAPSHOT
107 $ sed -i 's/-SNAPSHOT\(.*CURRENT_GRPC_VERSION\)/\1/' \
Eric Anderson554287a2016-06-16 10:12:41 -0700108 build.gradle android-interop-testing/app/build.gradle \
Eric Andersond7bf67e2016-06-24 18:18:06 -0700109 examples/build.gradle examples/pom.xml \
Naveen Reddy Chedeti28609592016-07-28 08:48:27 -0700110 examples/android/app/build.gradle examples/thrift/build.gradle
Eric Anderson7b26a322016-07-01 11:59:21 -0700111 $ ./gradlew build
Eric Andersonb8245652016-02-17 11:34:50 -0800112 $ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH"
113 $ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH"
nmittler483738e2015-06-08 14:32:37 -0700114 ```
Eric Andersonf25f55a2016-08-04 13:51:20 -07001156. Change root build files to the next snapshot version (e.g. `0.7.1-SNAPSHOT`).
Eric Anderson554287a2016-06-16 10:12:41 -0700116 Commit the result:
nmittler483738e2015-06-08 14:32:37 -0700117
118 ```bash
Eric Andersonb8245652016-02-17 11:34:50 -0800119 # Change version to next patch and add -SNAPSHOT
120 $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \
Eric Anderson554287a2016-06-16 10:12:41 -0700121 build.gradle android-interop-testing/app/build.gradle \
Eric Andersond7bf67e2016-06-24 18:18:06 -0700122 examples/build.gradle examples/pom.xml \
Naveen Reddy Chedeti28609592016-07-28 08:48:27 -0700123 examples/android/app/build.gradle examples/thrift/build.gradle
Eric Anderson7b26a322016-07-01 11:59:21 -0700124 $ ./gradlew build
Eric Andersonb8245652016-02-17 11:34:50 -0800125 $ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
126 ```
Eric Andersonf25f55a2016-08-04 13:51:20 -07001277. Go through PR review and push the release tag and updated release branch to
Eric Andersonb8245652016-02-17 11:34:50 -0800128 GitHub:
129
130 ```bash
131 $ git checkout v$MAJOR.$MINOR.x
132 $ git merge --ff-only release
133 $ git push upstream v$MAJOR.$MINOR.$PATCH
134 $ git push upstream v$MAJOR.$MINOR.x
nmittler483738e2015-06-08 14:32:37 -0700135 ```
136
137Setup Build Environment
138---------------------------
139
140### Linux
141The deployment for Linux uses [Docker](https://www.docker.com/) running
142CentOS 6.6 in order to ensure that we have a consistent deployment environment
143on Linux. You'll first need to install Docker if not already installed on your
Carl Mastrangelo8f6562e2015-08-13 15:19:53 -0700144system. Make sure to have at least version 1.7.1 or later.
nmittler483738e2015-06-08 14:32:37 -0700145
1461. Under the [Protobuf source directory](https://github.com/google/protobuf),
147 build the `protoc-artifacts` image:
148
149 ```bash
150 protobuf$ docker build -t protoc-artifacts protoc-artifacts
151 ```
1522. Under the grpc-java source directory, build the `grpc-java-deploy` image:
153
154 ```bash
155 grpc-java$ docker build -t grpc-java-deploy compiler
156 ```
1573. Start a Docker container that has the deploy environment set up for you. The
158 GRPC source is cloned into `/grpc-java`.
159
160 ```bash
161 $ docker run -it --rm=true grpc-java-deploy
162 ```
163
164 Note that the container will be deleted after you exit. Any changes you have
165 made (e.g., copied configuration files) will be lost. If you want to keep the
166 container, remove `--rm=true` from the command line.
1674. Next, you'll need to copy your OSSRH credentials and GnuPG keys to your docker container.
Kun Zhang2bd08872016-01-22 15:32:04 -0800168 In Docker:
169 ```
170 # mkdir /root/.gradle
171 ```
172 Find the container ID in your bash prompt, which is shown as `[root@<container-ID> ...]`.
173 In host:
174 ```
175 $ docker cp ~/.gnupg <container-ID>:/root/
176 $ docker cp ~/.gradle/gradle.properties <container-ID>:/root/.gradle/
nmittler483738e2015-06-08 14:32:37 -0700177 ```
178
179 You'll also need to update `signing.secretKeyRingFile` in
180 `/root/.gradle/gradle.properties` to point to `/root/.gnupg/secring.gpg`.
181
182### Windows
183
184#### Windows 64-bit with MSYS2 (Recommended for Windows)
185Because the gcc shipped with MSYS2 doesn't support multilib, you have to
186compile and deploy 32-bit and 64-bit binaries in separate steps.
187
188##### Under MinGW-w64 Win32 Shell
1891. Compile and install 32-bit protobuf:
190
191 ```bash
192 protobuf$ ./configure --disable-shared --prefix=$HOME/protobuf-32
193 protobuf$ make clean && make && make install
194 ```
1952. Configure CXXFLAGS needed by the protoc plugin when building.
196
197 ```bash
198 grpc-java$ export CXXFLAGS="-I$HOME/protobuf-32/include" \
199 LDFLAGS="-L$HOME/protobuf-32/lib"
200 ```
201
202##### Under MinGW-w64 Win64 Shell
2031. Compile and install 64-bit protobuf:
204
205 ```bash
206 protobuf$ ./configure --disable-shared --prefix=$HOME/protobuf-64
207 protobuf$ make clean && make && make install
208 ```
2092. Configure CXXFLAGS needed by the protoc plugin when building.
210
211 ```bash
212 grpc-java$ export CXXFLAGS="-I$HOME/protobuf-64/include" \
213 LDFLAGS="-L$HOME/protobuf-64/lib"
214 ```
215
216#### Windows 64-bit with Cygwin64 (TODO: incomplete)
217Because the MinGW gcc shipped with Cygwin64 doesn't support multilib, you have
218to compile and deploy 32-bit and 64-bit binaries in separate steps.
219
2201. Compile and install 32-bit protobuf. `-static-libgcc -static-libstdc++` are
221 needed for `protoc` to be successfully run in the unit test.
222
223 ```bash
224 protobuf$ LDFLAGS="-static-libgcc -static-libstdc++" ./configure --host=i686-w64-mingw32 --disable-shared --prefix=$HOME/protobuf-32
225 protobuf$ make clean && make && make install
226 ```
227
2282. Compile and install 64-bit protobuf:
229
230 ```bash
231 protobuf$ ./configure --host=x86_64-w64-mingw32 --disable-shared --prefix=$HOME/protobuf-64
232 protobuf$ make clean && make && make install
233 ```
234
235### Mac
236Please refer to [Protobuf
237README](https://github.com/google/protobuf/blob/master/README.md) for how to
238set up GCC and Unix tools on Mac.
239
240Mac OS X has been 64-bit-only since 10.7 and we are compiling for 10.7 and up.
241We only build 64-bit artifact for Mac.
242
2431. Compile and install protobuf:
244
245 ```bash
246 protobuf$ CXXFLAGS="-m64" ./configure --disable-shared --prefix=$HOME/protobuf
247 protobuf$ make clean && make && make install
248 ```
2492. Configure CXXFLAGS needed by the protoc plugin when building.
250
251 ```bash
252 grpc-java$ export CXXFLAGS="-I$HOME/protobuf/include" \
253 LDFLAGS="$HOME/protobuf/lib/libprotobuf.a $HOME/protobuf/lib/libprotoc.a"
254 ```
255
256Build and Deploy
257----------------
258We currently distribute the following OSes and architectures:
259
260| OS | x86_32 | x86_64 |
261| --- | --- | --- |
262| Linux | X | X |
263| Windows | X | X |
264| Mac | | X |
265
266Deployment to Maven Central (or the snapshot repo) is a two-step process. The only
267artifact that is platform-specific is codegen, so we only need to deploy the other
268jars once. So the first deployment is for all of the artifacts from one of the selected
269OS/architectures. After that, we then deploy the codegen artifacts for the remaining
270OS/architectures.
271
272**NOTE: _Before building/deploying, be sure to switch to the appropriate branch or tag in
273the grpc-java source directory._**
274
275### First Deployment
276
277As stated above, this only needs to be done once for one of the selected OS/architectures.
278The following command will build the whole project and upload it to Maven
Eric Anderson41a9c942016-04-29 15:19:24 -0700279Central. Parallel building [is not safe during
280uploadArchives](https://issues.gradle.org/browse/GRADLE-3420).
nmittler483738e2015-06-08 14:32:37 -0700281```bash
Eric Anderson41a9c942016-04-29 15:19:24 -0700282grpc-java$ ./gradlew clean build && ./gradlew -Dorg.gradle.parallel=false uploadArchives
nmittler483738e2015-06-08 14:32:37 -0700283```
284
285If the version has the `-SNAPSHOT` suffix, the artifacts will automatically
286go to the snapshot repository. Otherwise it's a release deployment and the
287artifacts will go to a freshly created staging repository.
288
289### Deploy GRPC Codegen for Additional Platforms
290The previous step will only deploy the codegen artifacts for the OS you run on
291it and the architecture of your JVM. For a fully fledged deployment, you will
292need to deploy the codegen for all other supported OSes and architectures.
293
294To deploy the codegen for an OS and architecture, you must run the following
295commands on that OS and specify the architecture by the flag `-PtargetArch=<arch>`.
296
297If you are doing a snapshot deployment:
298
299```bash
Eric Anderson41a9c942016-04-29 15:19:24 -0700300grpc-java$ ./gradlew clean grpc-compiler:build grpc-compiler:uploadArchives \
301 -PtargetArch=<arch> -Dorg.gradle.parallel=false
nmittler483738e2015-06-08 14:32:37 -0700302```
303
304When deploying a Release, the first deployment will create
305[a new staging repository](https://oss.sonatype.org/#stagingRepositories). You'll need
306to look up the ID in the OSSRH UI (usually in the form of `iogrpc-*`). Codegen
307deployment commands should include `-PrepositoryId=<repository-id>` in order to
308ensure that the artifacts are pushed to the same staging repository.
309
310```bash
311grpc-java$ ./gradlew clean grpc-compiler:build grpc-compiler:uploadArchives -PtargetArch=<arch> \
Eric Anderson41a9c942016-04-29 15:19:24 -0700312 -PrepositoryId=<repository-id> -Dorg.gradle.parallel=false
nmittler483738e2015-06-08 14:32:37 -0700313```
314
315Releasing on Maven Central
316--------------------------
317Once all of the artifacts have been pushed to the staging repository, the
318repository must first be `closed`, which will trigger several sanity checks
319on the repository. If this completes successfully, the repository can then
320be `released`, which will begin the process of pushing the new artifacts to
321Maven Central (the staging repository will be destroyed in the process). You can
322see the complete process for releasing to Maven Central on the [OSSRH site]
323(http://central.sonatype.org/pages/releasing-the-deployment.html).
324
Eric Andersonf25f55a2016-08-04 13:51:20 -0700325Update README.md
326----------------
327After waiting ~1 day and verifying that the release appears on [Maven Central]
328(http://mvnrepository.com/), cherry-pick the commit that updated the README into
329the master branch and go through review process.
330
331```
332$ git checkout -b bump-readme master
333$ git cherry-pick v$MAJOR.$MINOR.$PATCH^
334```
335
nmittler483738e2015-06-08 14:32:37 -0700336Notify the Community
337--------------------
Eric Andersonf25f55a2016-08-04 13:51:20 -0700338Finally, document and publicize the release.
nmittler483738e2015-06-08 14:32:37 -0700339
3401. Add [Release Notes](https://github.com/grpc/grpc-java/releases) for the new tag.
341 The description should include any major fixes or features since the last release.
342 You may choose to add links to bugs, PRs, or commits if appropriate.
3432. Post a release announcement to [grpc-io](https://groups.google.com/forum/#!forum/grpc-io)
344 (`grpc-io@googlegroups.com`). The title should be something that clearly identifies
345 the release (e.g.`GRPC-Java <tag> Released`).
Eric Andersone64c7552016-02-03 14:14:13 -0800346
Eric Andersone64c7552016-02-03 14:14:13 -0800347Update Hosted Javadoc
348---------------------
349
Eric Anderson27d84892016-03-10 16:28:35 -0800350Now we need to update gh-pages with the new Javadoc:
Eric Andersone64c7552016-02-03 14:14:13 -0800351
352```bash
353git checkout gh-pages
354rm -r javadoc/
Eric Anderson27d84892016-03-10 16:28:35 -0800355wget -O grpc-all-javadoc.jar "http://search.maven.org/remotecontent?filepath=io/grpc/grpc-all/$MAJOR.$MINOR.$PATCH/grpc-all-$MAJOR.$MINOR.$PATCH-javadoc.jar"
356unzip -d javadoc grpc-all-javadoc.jar
357rm grpc-all-javadoc.jar
Eric Andersone64c7552016-02-03 14:14:13 -0800358rm -r javadoc/META-INF/
359git add -A javadoc
Eric Anderson27d84892016-03-10 16:28:35 -0800360git commit -m "Javadoc for $MAJOR.$MINOR.$PATCH"
Eric Andersone64c7552016-02-03 14:14:13 -0800361```
362
363Push gh-pages to the main repository and verify the current version is [live
364on grpc.io](http://www.grpc.io/grpc-java/javadoc/).