| 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 |
| Bogdan Drutu | bd96a9c | 2017-10-23 12:35:01 -0700 | [diff] [blame] | 68 | api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 69 | ) |
| 70 | $ git checkout -b v$MAJOR.$MINOR.x master |
| 71 | $ git push upstream v$MAJOR.$MINOR.x |
| 72 | ``` |
| 73 | |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 74 | 2. Enable branch protection for the new branch, if you have admin access. |
| 75 | Otherwise, let someone with admin access know that there is a new release |
| 76 | branch. |
| 77 | |
| 78 | - Open the branch protection settings for the new branch, by following |
| 79 | [Github's instructions](https://help.github.com/articles/configuring-protected-branches/). |
| 80 | - Copy the settings from a previous branch, i.e., check |
| 81 | - `Protect this branch` |
| 82 | - `Require pull request reviews before merging` |
| 83 | - `Require status checks to pass before merging` |
| 84 | - `Include administrators` |
| 85 | |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 86 | Enable the following required status checks: |
| 87 | - `cla/google` |
| 88 | - `continuous-integration/appveyor/pr` |
| 89 | - `continuous-integration/travis-ci` |
| Kristen Kozak | d1a7aaf | 2017-09-11 11:13:53 -0700 | [diff] [blame] | 90 | - Uncheck everything else. |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 91 | - Click "Save changes". |
| 92 | |
| 93 | 3. For `master` branch: |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 94 | |
| 95 | - Change root build files to the next minor snapshot (e.g. |
| 96 | `0.5.0-SNAPSHOT`). |
| 97 | |
| 98 | ```bash |
| 99 | $ git checkout -b bump-version master |
| 100 | # Change version to next minor (and keep -SNAPSHOT) |
| Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 101 | $ 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] | 102 | "${VERSION_FILES[@]}" |
| 103 | $ ./gradlew build |
| 104 | $ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle" |
| 105 | ``` |
| 106 | |
| 107 | - Go through PR review and push the master branch to GitHub: |
| 108 | |
| 109 | ```bash |
| 110 | $ git checkout master |
| 111 | $ git merge --ff-only bump-version |
| 112 | $ git push upstream master |
| 113 | ``` |
| 114 | |
| Kristen Kozak | feda64e | 2017-09-08 17:59:07 -0700 | [diff] [blame] | 115 | 4. For `vMajor.Minor.x` branch: |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 116 | |
| 117 | - Change root build files to remove "-SNAPSHOT" for the next release |
| 118 | version (e.g. `0.4.0`). Commit the result and make a tag: |
| 119 | |
| 120 | ```bash |
| 121 | $ git checkout -b release v$MAJOR.$MINOR.x |
| 122 | # Change version to remove -SNAPSHOT |
| Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 123 | $ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_VERSION\)/\1/' "${VERSION_FILES[@]}" |
| Bogdan Drutu | 4e1c4fc | 2017-04-13 19:50:36 -0700 | [diff] [blame] | 124 | $ ./gradlew build |
| 125 | $ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH" |
| 126 | $ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH" |
| 127 | ``` |
| 128 | |
| 129 | - Change root build files to the next snapshot version (e.g. |
| 130 | `0.4.1-SNAPSHOT`). Commit the result: |
| 131 | |
| 132 | ```bash |
| 133 | # Change version to next patch and add -SNAPSHOT |
| Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 134 | $ 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] | 135 | "${VERSION_FILES[@]}" |
| 136 | $ ./gradlew build |
| 137 | $ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT" |
| 138 | ``` |
| 139 | |
| 140 | - Go through PR review and push the release tag and updated release branch |
| 141 | to GitHub: |
| 142 | |
| 143 | ```bash |
| 144 | $ git checkout v$MAJOR.$MINOR.x |
| 145 | $ git merge --ff-only release |
| 146 | $ git push upstream v$MAJOR.$MINOR.$PATCH |
| 147 | $ git push upstream v$MAJOR.$MINOR.x |
| 148 | ``` |
| Bogdan Drutu | ac9dd02 | 2017-04-17 13:03:01 -0700 | [diff] [blame] | 149 | |
| 150 | ## Deployment |
| 151 | |
| 152 | Deployment to Maven Central (or the snapshot repo) is for all of the artifacts |
| 153 | from the project. |
| 154 | |
| 155 | ### Branch |
| 156 | |
| 157 | Before building/deploying, be sure to switch to the appropriate branch or tag. |
| 158 | For the current release use: |
| 159 | |
| 160 | ```bash |
| 161 | $ git checkout -b v$MAJOR.$MINOR.$PATCH tags/v$MAJOR.$MINOR.$PATCH |
| 162 | ``` |
| 163 | |
| 164 | ### Initial Deployment |
| 165 | |
| 166 | The following command will build the whole project and upload it to Maven |
| 167 | Central. Parallel building [is not safe during |
| 168 | uploadArchives](https://issues.gradle.org/browse/GRADLE-3420). |
| 169 | |
| 170 | ```bash |
| 171 | $ ./gradlew clean build && ./gradlew -Dorg.gradle.parallel=false uploadArchives |
| 172 | ``` |
| 173 | |
| 174 | If the version has the `-SNAPSHOT` suffix, the artifacts will automatically go |
| 175 | to the snapshot repository. Otherwise it's a release deployment and the |
| 176 | artifacts will go to a staging repository. |
| 177 | |
| 178 | When deploying a Release, the deployment will create [a new staging |
| 179 | repository](https://oss.sonatype.org/#stagingRepositories). You'll need to look |
| Bogdan Drutu | ce8ad4b | 2017-07-07 12:26:21 -0700 | [diff] [blame] | 180 | 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] | 181 | |
| 182 | ## Releasing on Maven Central |
| 183 | |
| 184 | Once all of the artifacts have been pushed to the staging repository, the |
| 185 | repository must first be `closed`, which will trigger several sanity checks on |
| 186 | the repository. If this completes successfully, the repository can then be |
| 187 | `released`, which will begin the process of pushing the new artifacts to Maven |
| 188 | Central (the staging repository will be destroyed in the process). You can see |
| 189 | the complete process for releasing to Maven Central on the [OSSRH |
| 190 | site](http://central.sonatype.org/pages/releasing-the-deployment.html). |
| Bogdan Drutu | c796e25 | 2017-07-07 16:42:36 -0700 | [diff] [blame] | 191 | |
| 192 | ## Known Issues |
| 193 | |
| Bogdan Drutu | 6684c2b | 2017-07-10 13:59:40 -0700 | [diff] [blame] | 194 | ### Deployment for tag v0.5.0 |
| 195 | To rebuild the releases on the tag v0.5.0 use: |
| Bogdan Drutu | c796e25 | 2017-07-07 16:42:36 -0700 | [diff] [blame] | 196 | ```bash |
| 197 | $ ./gradlew clean build && ./gradlew uploadArchives |
| 198 | ``` |
| 199 | |
| 200 | If option `-Dorg.gradle.parallel=false` is used, you will hit [this bug](https://issues.sonatype.org/browse/OSSRH-19485) |
| 201 | caused by [this bug](https://github.com/gradle/gradle/issues/1827) in gradle 3.5. |