| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 1 | # How to Create a Release of OpenCensus Java (for Maintainers Only) |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 2 | |
| 3 | ## Build Environments |
| 4 | |
| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 5 | We deploy OpenCensus Java to Maven Central under the following systems: |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 6 | |
| 7 | - Ubuntu 14.04 |
| 8 | |
| 9 | Other systems may also work, but we haven't verified them. |
| 10 | |
| 11 | ## Prerequisites |
| 12 | |
| 13 | ### Setup OSSRH and Signing |
| 14 | |
| 15 | If you haven't deployed artifacts to Maven Central before, you need to setup |
| 16 | your OSSRH (OSS Repository Hosting) account and signing keys. |
| 17 | |
| 18 | - Follow the instructions on [this |
| 19 | page](http://central.sonatype.org/pages/ossrh-guide.html) to set up an |
| 20 | account with OSSRH. |
| 21 | - You only need to create the account, not set up a new project |
| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 22 | - Contact a OpenCensus Java maintainer on JIRA to add your account after you |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 23 | have created it. |
| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 24 | - Comment under [this JIRA bug](https://issues.sonatype.org/browse/OSSRH-32121) |
| 25 | for release permission to io.opencensus. |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 26 | - (For release deployment only) [Install |
| 27 | GnuPG](http://central.sonatype.org/pages/working-with-pgp-signatures.html#installing-gnupg) |
| 28 | and [generate your key |
| 29 | pair](http://central.sonatype.org/pages/working-with-pgp-signatures.html#generating-a-key-pair). |
| 30 | You'll also need to [publish your public |
| 31 | key](http://central.sonatype.org/pages/working-with-pgp-signatures.html#distributing-your-public-key) |
| 32 | to make it visible to the Sonatype servers. |
| 33 | - Put your GnuPG key password and OSSRH account information in |
| 34 | `<your-home-directory>/.gradle/gradle.properties`: |
| 35 | |
| 36 | ``` |
| 37 | # You need the signing properties only if you are making release deployment |
| 38 | signing.keyId=<8-character-public-key-id> |
| 39 | signing.password=<key-password> |
| 40 | signing.secretKeyRingFile=<your-home-directory>/.gnupg/secring.gpg |
| 41 | |
| 42 | ossrhUsername=<ossrh-username> |
| 43 | ossrhPassword=<ossrh-password> |
| 44 | checkstyle.ignoreFailures=false |
| 45 | ``` |
| 46 | |
| 47 | ## Tagging the Release |
| 48 | |
| 49 | The first step in the release process is to create a release branch, bump |
| 50 | versions, and create a tag for the release. Our release branches follow the |
| 51 | naming convention of `v<major>.<minor>.x`, while the tags include the patch |
| 52 | version `v<major>.<minor>.<patch>`. For example, the same branch `v0.4.x` would |
| 53 | be used to create all `v0.4` tags (e.g. `v0.4.0`, `v0.4.1`). |
| 54 | |
| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 55 | In this section upstream repository refers to the main opencensus-java github |
| 56 | repository. |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 57 | |
| Bogdan Drutu | ac9dd02 | 2017-04-17 13:03:01 -0700 | [diff] [blame] | 58 | Before any push to the upstream repository you need to create a [personal access |
| 59 | token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). |
| 60 | |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 61 | 1. Create the release branch and push it to GitHub: |
| 62 | |
| 63 | ```bash |
| 64 | $ MAJOR=0 MINOR=4 PATCH=0 # Set appropriately for new release |
| 65 | $ VERSION_FILES=( |
| 66 | build.gradle |
| Bogdan Drutu | fc71453 | 2018-01-18 19:09:03 -0800 | [diff] [blame] | 67 | examples/build.gradle |
| Hailong Wen | 916e10e | 2018-01-19 16:30:14 -0800 | [diff] [blame] | 68 | examples/pom.xml |
| Bogdan Drutu | bd96a9c | 2017-10-23 12:35:01 -0700 | [diff] [blame] | 69 | api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 70 | ) |
| 71 | $ git checkout -b v$MAJOR.$MINOR.x master |
| 72 | $ git push upstream v$MAJOR.$MINOR.x |
| 73 | ``` |
| 74 | |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 75 | 2. Enable branch protection for the new branch, if you have admin access. |
| 76 | Otherwise, let someone with admin access know that there is a new release |
| 77 | branch. |
| 78 | |
| 79 | - Open the branch protection settings for the new branch, by following |
| 80 | [Github's instructions](https://help.github.com/articles/configuring-protected-branches/). |
| 81 | - Copy the settings from a previous branch, i.e., check |
| 82 | - `Protect this branch` |
| 83 | - `Require pull request reviews before merging` |
| 84 | - `Require status checks to pass before merging` |
| 85 | - `Include administrators` |
| 86 | |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 87 | Enable the following required status checks: |
| 88 | - `cla/google` |
| 89 | - `continuous-integration/appveyor/pr` |
| 90 | - `continuous-integration/travis-ci` |
| Kristen Kozak | d1a7aaf | 2017-09-11 11:13:53 -0700 | [diff] [blame] | 91 | - Uncheck everything else. |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 92 | - Click "Save changes". |
| 93 | |
| 94 | 3. For `master` branch: |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 95 | |
| 96 | - Change root build files to the next minor snapshot (e.g. |
| 97 | `0.5.0-SNAPSHOT`). |
| 98 | |
| 99 | ```bash |
| 100 | $ git checkout -b bump-version master |
| 101 | # Change version to next minor (and keep -SNAPSHOT) |
| Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 102 | $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \ |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 103 | "${VERSION_FILES[@]}" |
| 104 | $ ./gradlew build |
| 105 | $ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle" |
| 106 | ``` |
| 107 | |
| 108 | - Go through PR review and push the master branch to GitHub: |
| 109 | |
| 110 | ```bash |
| 111 | $ git checkout master |
| 112 | $ git merge --ff-only bump-version |
| 113 | $ git push upstream master |
| 114 | ``` |
| 115 | |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 116 | 4. For `vMajor.Minor.x` branch: |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 117 | |
| 118 | - Change root build files to remove "-SNAPSHOT" for the next release |
| 119 | version (e.g. `0.4.0`). Commit the result and make a tag: |
| 120 | |
| 121 | ```bash |
| 122 | $ git checkout -b release v$MAJOR.$MINOR.x |
| 123 | # Change version to remove -SNAPSHOT |
| Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 124 | $ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_VERSION\)/\1/' "${VERSION_FILES[@]}" |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 125 | $ ./gradlew build |
| 126 | $ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH" |
| 127 | $ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH" |
| 128 | ``` |
| 129 | |
| 130 | - Change root build files to the next snapshot version (e.g. |
| 131 | `0.4.1-SNAPSHOT`). Commit the result: |
| 132 | |
| 133 | ```bash |
| 134 | # Change version to next patch and add -SNAPSHOT |
| Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 135 | $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \ |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 136 | "${VERSION_FILES[@]}" |
| 137 | $ ./gradlew build |
| 138 | $ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT" |
| 139 | ``` |
| 140 | |
| 141 | - Go through PR review and push the release tag and updated release branch |
| 142 | to GitHub: |
| 143 | |
| 144 | ```bash |
| 145 | $ git checkout v$MAJOR.$MINOR.x |
| 146 | $ git merge --ff-only release |
| 147 | $ git push upstream v$MAJOR.$MINOR.$PATCH |
| 148 | $ git push upstream v$MAJOR.$MINOR.x |
| 149 | ``` |
| Bogdan Drutu | ac9dd02 | 2017-04-17 13:03:01 -0700 | [diff] [blame] | 150 | |
| 151 | ## Deployment |
| 152 | |
| 153 | Deployment to Maven Central (or the snapshot repo) is for all of the artifacts |
| 154 | from the project. |
| 155 | |
| 156 | ### Branch |
| 157 | |
| Kristen Kozak | 0f28b17 | 2018-05-01 14:40:29 -0700 | [diff] [blame] | 158 | Before building/deploying, be sure to switch to the appropriate tag. The tag |
| 159 | must reference a commit that has been pushed to the main repository, i.e., has |
| 160 | gone through code review. For the current release use: |
| Bogdan Drutu | ac9dd02 | 2017-04-17 13:03:01 -0700 | [diff] [blame] | 161 | |
| 162 | ```bash |
| 163 | $ git checkout -b v$MAJOR.$MINOR.$PATCH tags/v$MAJOR.$MINOR.$PATCH |
| 164 | ``` |
| 165 | |
| 166 | ### Initial Deployment |
| 167 | |
| 168 | The following command will build the whole project and upload it to Maven |
| 169 | Central. Parallel building [is not safe during |
| 170 | uploadArchives](https://issues.gradle.org/browse/GRADLE-3420). |
| 171 | |
| 172 | ```bash |
| 173 | $ ./gradlew clean build && ./gradlew -Dorg.gradle.parallel=false uploadArchives |
| 174 | ``` |
| 175 | |
| 176 | If the version has the `-SNAPSHOT` suffix, the artifacts will automatically go |
| 177 | to the snapshot repository. Otherwise it's a release deployment and the |
| 178 | artifacts will go to a staging repository. |
| 179 | |
| 180 | When deploying a Release, the deployment will create [a new staging |
| 181 | repository](https://oss.sonatype.org/#stagingRepositories). You'll need to look |
| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 182 | up the ID in the OSSRH UI (usually in the form of `opencensus-*`). |
| Bogdan Drutu | ac9dd02 | 2017-04-17 13:03:01 -0700 | [diff] [blame] | 183 | |
| 184 | ## Releasing on Maven Central |
| 185 | |
| 186 | Once all of the artifacts have been pushed to the staging repository, the |
| 187 | repository must first be `closed`, which will trigger several sanity checks on |
| 188 | the repository. If this completes successfully, the repository can then be |
| 189 | `released`, which will begin the process of pushing the new artifacts to Maven |
| 190 | Central (the staging repository will be destroyed in the process). You can see |
| 191 | the complete process for releasing to Maven Central on the [OSSRH |
| 192 | site](http://central.sonatype.org/pages/releasing-the-deployment.html). |
| Bogdan Drutu | c796e25 | 2017-07-07 16:42:36 -0700 | [diff] [blame] | 193 | |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 194 | ## Announcement |
| 195 | |
| 196 | Once deployment is done, go to Github [release |
| 197 | page](https://github.com/census-instrumentation/opencensus-java/releases), press |
| 198 | `Draft a new release` to write release notes about the new release. |
| 199 | |
| 200 | You can use `git log upstream/v$MAJOR.$((MINOR-1)).x..upstream/v$MAJOR.$MINOR.x --graph --first-parent` |
| 201 | or the Github [compare tool](https://github.com/census-instrumentation/opencensus-java/compare/) |
| Yang Song | b09b328 | 2018-04-27 16:07:18 -0700 | [diff] [blame] | 202 | to view a summary of all commits since last release as a reference. In addition, you can refer to |
| 203 | [CHANGELOG.md](https://github.com/census-instrumentation/opencensus-java/blob/master/CHANGELOG.md) |
| 204 | for a list of major changes since last release. |
| 205 | |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 206 | Please pick major or important user-visible changes only. |
| 207 | |
| 208 | ## Update release versions in documentations and build files |
| 209 | |
| 210 | After releasing is done, you need to update all readmes and examples to point to the |
| 211 | latest version. |
| 212 | |
| 213 | 1. Update README.md and gradle/maven build files on `master` branch: |
| 214 | |
| 215 | ```bash |
| 216 | $ git checkout -b bump-document-version master |
| 217 | $ BUILD_FILES=( |
| 218 | examples/build.gradle |
| 219 | examples/pom.xml |
| 220 | ) |
| 221 | $ README_FILES=( |
| 222 | README.md |
| Yang Song | 432d0a9 | 2018-06-05 10:35:35 -0700 | [diff] [blame] | 223 | contrib/appengine_standard_util/README.md |
| Yang Song | d3a3fbf | 2018-07-12 12:02:14 -0700 | [diff] [blame] | 224 | contrib/exemplar_util/README.md |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 225 | contrib/grpc_util/README.md |
| 226 | contrib/http_util/README.md |
| sebright | 8a95c21 | 2018-09-04 10:26:22 -0700 | [diff] [blame] | 227 | contrib/log_correlation/log4j/README.md |
| Kristen Kozak | 81f5abb | 2018-06-19 18:13:48 -0700 | [diff] [blame] | 228 | contrib/log_correlation/stackdriver/README.md |
| Yang Song | a3b50ea | 2018-05-21 15:32:23 -0700 | [diff] [blame] | 229 | contrib/monitored_resource_util/README.md |
| savaki | 9dad959 | 2018-07-19 19:32:00 -0700 | [diff] [blame] | 230 | contrib/spring/README.md |
| Dino Oliva | 30c10cc | 2018-09-05 12:09:44 -0700 | [diff] [blame] | 231 | contrib/spring_sleuth/README.md |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 232 | contrib/zpages/README.md |
| Yang Song | b0d3967 | 2018-02-13 12:47:32 -0800 | [diff] [blame] | 233 | exporters/stats/prometheus/README.md |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 234 | exporters/stats/signalfx/README.md |
| 235 | exporters/stats/stackdriver/README.md |
| Fabian Lange | 17a1a1a | 2018-02-09 14:33:30 -0500 | [diff] [blame] | 236 | exporters/trace/instana/README.md |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 237 | exporters/trace/logging/README.md |
| Yang Song | 9b6eb8c | 2018-03-16 11:00:43 -0700 | [diff] [blame] | 238 | exporters/trace/jaeger/README.md |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 239 | exporters/trace/stackdriver/README.md |
| 240 | exporters/trace/zipkin/README.md |
| 241 | ) |
| 242 | # Substitute versions in build files |
| 243 | $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*LATEST_OPENCENSUS_RELEASE_VERSION\)/'$MAJOR.$MINOR.$PATCH'\1/' \ |
| 244 | "${BUILD_FILES[@]}" |
| 245 | # Substitute versions in build.gradle examples in README.md |
| 246 | $ sed -i 's/\(\(compile\|runtime\).\+io\.opencensus:.\+:\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1'$MAJOR.$MINOR.$PATCH'/' \ |
| 247 | "${README_FILES[@]}" |
| 248 | # Substitute versions in maven pom examples in README.md |
| 249 | $ sed -i 's/\(<version>\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1'$MAJOR.$MINOR.$PATCH'/' \ |
| 250 | "${README_FILES[@]}" |
| 251 | ``` |
| 252 | |
| 253 | 2. Update bazel dependencies for subproject `examples`: |
| 254 | |
| 255 | - Follow the instructions on [this |
| 256 | page](https://docs.bazel.build/versions/master/generate-workspace.html) to |
| 257 | install bazel migration tool. You may also need to manually apply |
| 258 | this [patch]( |
| 259 | https://github.com/nevillelyh/migration-tooling/commit/f10e14fd18ad3885c7ec8aa305e4eba266a07ebf) |
| 260 | if you encounter `Unable to find a version for ... due to Invalid Range Result` error when |
| 261 | using it. |
| 262 | |
| 263 | - Use the following command to generate new dependencies file: |
| 264 | |
| 265 | ```bash |
| 266 | $ bazel run //generate_workspace -- \ |
| Yang Song | 751ea3c | 2018-03-20 10:44:54 -0700 | [diff] [blame] | 267 | --artifact=com.google.guava:guava:23.0 \ |
| 268 | --artifact=io.grpc:grpc-all:1.9.0 \ |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 269 | --artifact=io.opencensus:opencensus-api:$MAJOR.$MINOR.$PATCH \ |
| Yang Song | 751ea3c | 2018-03-20 10:44:54 -0700 | [diff] [blame] | 270 | --artifact=io.opencensus:opencensus-contrib-grpc-metrics:$MAJOR.$MINOR.$PATCH \ |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 271 | --artifact=io.opencensus:opencensus-contrib-zpages:$MAJOR.$MINOR.$PATCH \ |
| Yang Song | 751ea3c | 2018-03-20 10:44:54 -0700 | [diff] [blame] | 272 | --artifact=io.opencensus:opencensus-exporter-stats-prometheus:$MAJOR.$MINOR.$PATCH \ |
| 273 | --artifact=io.opencensus:opencensus-exporter-stats-stackdriver:$MAJOR.$MINOR.$PATCH \ |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 274 | --artifact=io.opencensus:opencensus-exporter-trace-logging:$MAJOR.$MINOR.$PATCH \ |
| Yang Song | 751ea3c | 2018-03-20 10:44:54 -0700 | [diff] [blame] | 275 | --artifact=io.opencensus:opencensus-exporter-trace-stackdriver:$MAJOR.$MINOR.$PATCH \ |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 276 | --artifact=io.opencensus:opencensus-impl:$MAJOR.$MINOR.$PATCH \ |
| Yang Song | 751ea3c | 2018-03-20 10:44:54 -0700 | [diff] [blame] | 277 | --artifact=io.prometheus:simpleclient_httpserver:0.3.0 \ |
| Hailong Wen | e9b6178 | 2018-01-22 14:18:36 -0800 | [diff] [blame] | 278 | --repositories=http://repo.maven.apache.org/maven2 |
| 279 | Wrote |
| 280 | /usr/local/.../generate_workspace.runfiles/__main__/generate_workspace.bzl |
| 281 | ``` |
| 282 | |
| 283 | - Copy this file to overwrite `examples/opencensus_workspace.bzl`. |
| 284 | |
| 285 | - Use the following command to rename the generated rules and commit the |
| 286 | changes above: |
| 287 | |
| 288 | ```bash |
| 289 | $ sed -i 's/def generated_/def opencensus_/' examples/opencensus_workspace.bzl |
| 290 | $ git commit -a -m "Update release versions for all readme and build files." |
| 291 | ``` |
| 292 | |
| 293 | 3. Go through PR review and merge it to GitHub master branch. |
| 294 | |
| Yang Song | e812bcf | 2018-05-03 16:26:52 -0700 | [diff] [blame] | 295 | 4. In addition, create a PR to mark the new release in |
| 296 | [CHANGELOG.md](https://github.com/census-instrumentation/opencensus-java/blob/master/CHANGELOG.md) |
| 297 | on master branch. Once that PR is merged, cherry-pick the commit and create another PR to the |
| 298 | release branch (branch v$MAJOR.$MINOR.x). |
| 299 | |
| 300 | |
| Bogdan Drutu | c796e25 | 2017-07-07 16:42:36 -0700 | [diff] [blame] | 301 | ## Known Issues |
| 302 | |
| Bogdan Drutu | 6684c2b | 2017-07-10 13:59:40 -0700 | [diff] [blame] | 303 | ### Deployment for tag v0.5.0 |
| 304 | To rebuild the releases on the tag v0.5.0 use: |
| Bogdan Drutu | c796e25 | 2017-07-07 16:42:36 -0700 | [diff] [blame] | 305 | ```bash |
| 306 | $ ./gradlew clean build && ./gradlew uploadArchives |
| 307 | ``` |
| 308 | |
| 309 | If option `-Dorg.gradle.parallel=false` is used, you will hit [this bug](https://issues.sonatype.org/browse/OSSRH-19485) |
| 310 | caused by [this bug](https://github.com/gradle/gradle/issues/1827) in gradle 3.5. |