1*a24ffb47SSadaf Ebrahimi# How to Create a Release of OpenCensus Java (for Maintainers Only) 2*a24ffb47SSadaf Ebrahimi 3*a24ffb47SSadaf Ebrahimi## Build Environments 4*a24ffb47SSadaf Ebrahimi 5*a24ffb47SSadaf EbrahimiWe deploy OpenCensus Java to Maven Central under the following systems: 6*a24ffb47SSadaf Ebrahimi 7*a24ffb47SSadaf Ebrahimi- Ubuntu 14.04 8*a24ffb47SSadaf Ebrahimi 9*a24ffb47SSadaf EbrahimiOther systems may also work, but we haven't verified them. 10*a24ffb47SSadaf Ebrahimi 11*a24ffb47SSadaf Ebrahimi## Prerequisites 12*a24ffb47SSadaf Ebrahimi 13*a24ffb47SSadaf Ebrahimi### Setup OSSRH and Signing 14*a24ffb47SSadaf Ebrahimi 15*a24ffb47SSadaf EbrahimiIf you haven't deployed artifacts to Maven Central before, you need to setup 16*a24ffb47SSadaf Ebrahimiyour OSSRH (OSS Repository Hosting) account and signing keys. 17*a24ffb47SSadaf Ebrahimi 18*a24ffb47SSadaf Ebrahimi- Follow the instructions on [this 19*a24ffb47SSadaf Ebrahimi page](http://central.sonatype.org/pages/ossrh-guide.html) to set up an 20*a24ffb47SSadaf Ebrahimi account with OSSRH. 21*a24ffb47SSadaf Ebrahimi - You only need to create the account, not set up a new project 22*a24ffb47SSadaf Ebrahimi - Contact a OpenCensus Java maintainer to add your account after you 23*a24ffb47SSadaf Ebrahimi have created it. 24*a24ffb47SSadaf Ebrahimi- (For release deployment only) [Install 25*a24ffb47SSadaf Ebrahimi GnuPG](http://central.sonatype.org/pages/working-with-pgp-signatures.html#installing-gnupg) 26*a24ffb47SSadaf Ebrahimi and [generate your key 27*a24ffb47SSadaf Ebrahimi pair](http://central.sonatype.org/pages/working-with-pgp-signatures.html#generating-a-key-pair). 28*a24ffb47SSadaf Ebrahimi You'll also need to [publish your public 29*a24ffb47SSadaf Ebrahimi key](http://central.sonatype.org/pages/working-with-pgp-signatures.html#distributing-your-public-key) 30*a24ffb47SSadaf Ebrahimi to make it visible to the Sonatype servers. 31*a24ffb47SSadaf Ebrahimi- Put your GnuPG key password and OSSRH account information in 32*a24ffb47SSadaf Ebrahimi `<your-home-directory>/.gradle/gradle.properties`: 33*a24ffb47SSadaf Ebrahimi 34*a24ffb47SSadaf Ebrahimi ``` 35*a24ffb47SSadaf Ebrahimi # You need the signing properties only if you are making release deployment 36*a24ffb47SSadaf Ebrahimi signing.keyId=<8-character-public-key-id> 37*a24ffb47SSadaf Ebrahimi signing.password=<key-password> 38*a24ffb47SSadaf Ebrahimi signing.secretKeyRingFile=<your-home-directory>/.gnupg/secring.gpg 39*a24ffb47SSadaf Ebrahimi 40*a24ffb47SSadaf Ebrahimi ossrhUsername=<ossrh-username> 41*a24ffb47SSadaf Ebrahimi ossrhPassword=<ossrh-password> 42*a24ffb47SSadaf Ebrahimi checkstyle.ignoreFailures=false 43*a24ffb47SSadaf Ebrahimi ``` 44*a24ffb47SSadaf Ebrahimi 45*a24ffb47SSadaf Ebrahimi## Tagging the Release 46*a24ffb47SSadaf Ebrahimi 47*a24ffb47SSadaf EbrahimiThe first step in the release process is to create a release branch, bump 48*a24ffb47SSadaf Ebrahimiversions, and create a tag for the release. Our release branches follow the 49*a24ffb47SSadaf Ebrahiminaming convention of `v<major>.<minor>.x`, while the tags include the patch 50*a24ffb47SSadaf Ebrahimiversion `v<major>.<minor>.<patch>`. For example, the same branch `v0.4.x` would 51*a24ffb47SSadaf Ebrahimibe used to create all `v0.4` tags (e.g. `v0.4.0`, `v0.4.1`). 52*a24ffb47SSadaf Ebrahimi 53*a24ffb47SSadaf EbrahimiIn this section upstream repository refers to the main opencensus-java github 54*a24ffb47SSadaf Ebrahimirepository. 55*a24ffb47SSadaf Ebrahimi 56*a24ffb47SSadaf EbrahimiBefore any push to the upstream repository you need to create a [personal access 57*a24ffb47SSadaf Ebrahimitoken](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). 58*a24ffb47SSadaf Ebrahimi 59*a24ffb47SSadaf Ebrahimi1. Create the release branch and push it to GitHub: 60*a24ffb47SSadaf Ebrahimi 61*a24ffb47SSadaf Ebrahimi ```bash 62*a24ffb47SSadaf Ebrahimi $ MAJOR=0 MINOR=4 PATCH=0 # Set appropriately for new release 63*a24ffb47SSadaf Ebrahimi $ VERSION_FILES=( 64*a24ffb47SSadaf Ebrahimi build.gradle 65*a24ffb47SSadaf Ebrahimi examples/build.gradle 66*a24ffb47SSadaf Ebrahimi examples/pom.xml 67*a24ffb47SSadaf Ebrahimi api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java 68*a24ffb47SSadaf Ebrahimi exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java 69*a24ffb47SSadaf Ebrahimi exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java 70*a24ffb47SSadaf Ebrahimi examples/spring/servlet/build.gradle 71*a24ffb47SSadaf Ebrahimi examples/spring/servlet/pom.xml 72*a24ffb47SSadaf Ebrahimi ) 73*a24ffb47SSadaf Ebrahimi $ git checkout -b v$MAJOR.$MINOR.x master 74*a24ffb47SSadaf Ebrahimi $ git push upstream v$MAJOR.$MINOR.x 75*a24ffb47SSadaf Ebrahimi ``` 76*a24ffb47SSadaf Ebrahimi The branch will be automatically protected by the GitHub branch protection rule for release 77*a24ffb47SSadaf Ebrahimi branches. 78*a24ffb47SSadaf Ebrahimi 79*a24ffb47SSadaf Ebrahimi2. For `master` branch: 80*a24ffb47SSadaf Ebrahimi 81*a24ffb47SSadaf Ebrahimi - Change root build files to the next minor snapshot (e.g. 82*a24ffb47SSadaf Ebrahimi `0.5.0-SNAPSHOT`). 83*a24ffb47SSadaf Ebrahimi 84*a24ffb47SSadaf Ebrahimi ```bash 85*a24ffb47SSadaf Ebrahimi $ git checkout -b bump-version master 86*a24ffb47SSadaf Ebrahimi # Change version to next minor (and keep -SNAPSHOT) 87*a24ffb47SSadaf Ebrahimi $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \ 88*a24ffb47SSadaf Ebrahimi "${VERSION_FILES[@]}" 89*a24ffb47SSadaf Ebrahimi $ ./gradlew build 90*a24ffb47SSadaf Ebrahimi $ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle" 91*a24ffb47SSadaf Ebrahimi ``` 92*a24ffb47SSadaf Ebrahimi 93*a24ffb47SSadaf Ebrahimi - Go through PR review and push the master branch to GitHub: 94*a24ffb47SSadaf Ebrahimi 95*a24ffb47SSadaf Ebrahimi ```bash 96*a24ffb47SSadaf Ebrahimi $ git checkout master 97*a24ffb47SSadaf Ebrahimi $ git merge --ff-only bump-version 98*a24ffb47SSadaf Ebrahimi $ git push upstream master 99*a24ffb47SSadaf Ebrahimi ``` 100*a24ffb47SSadaf Ebrahimi 101*a24ffb47SSadaf Ebrahimi3. For `vMajor.Minor.x` branch: 102*a24ffb47SSadaf Ebrahimi 103*a24ffb47SSadaf Ebrahimi - Change root build files to remove "-SNAPSHOT" for the next release 104*a24ffb47SSadaf Ebrahimi version (e.g. `0.4.0`). Commit the result and make a tag: 105*a24ffb47SSadaf Ebrahimi 106*a24ffb47SSadaf Ebrahimi ```bash 107*a24ffb47SSadaf Ebrahimi $ git checkout -b release v$MAJOR.$MINOR.x 108*a24ffb47SSadaf Ebrahimi # Change version to remove -SNAPSHOT 109*a24ffb47SSadaf Ebrahimi $ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_VERSION\)/\1/' "${VERSION_FILES[@]}" 110*a24ffb47SSadaf Ebrahimi $ ./gradlew build 111*a24ffb47SSadaf Ebrahimi $ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH" 112*a24ffb47SSadaf Ebrahimi $ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH" 113*a24ffb47SSadaf Ebrahimi ``` 114*a24ffb47SSadaf Ebrahimi 115*a24ffb47SSadaf Ebrahimi - Change root build files to the next snapshot version (e.g. 116*a24ffb47SSadaf Ebrahimi `0.4.1-SNAPSHOT`). Commit the result: 117*a24ffb47SSadaf Ebrahimi 118*a24ffb47SSadaf Ebrahimi ```bash 119*a24ffb47SSadaf Ebrahimi # Change version to next patch and add -SNAPSHOT 120*a24ffb47SSadaf Ebrahimi $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \ 121*a24ffb47SSadaf Ebrahimi "${VERSION_FILES[@]}" 122*a24ffb47SSadaf Ebrahimi $ ./gradlew build 123*a24ffb47SSadaf Ebrahimi $ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT" 124*a24ffb47SSadaf Ebrahimi ``` 125*a24ffb47SSadaf Ebrahimi 126*a24ffb47SSadaf Ebrahimi - Go through PR review and push the release tag and updated release branch 127*a24ffb47SSadaf Ebrahimi to GitHub (note: do not squash the commits when you merge otherwise you 128*a24ffb47SSadaf Ebrahimi will lose the release tag): 129*a24ffb47SSadaf Ebrahimi 130*a24ffb47SSadaf Ebrahimi ```bash 131*a24ffb47SSadaf Ebrahimi $ git checkout v$MAJOR.$MINOR.x 132*a24ffb47SSadaf Ebrahimi $ git merge --ff-only release 133*a24ffb47SSadaf Ebrahimi $ git push upstream v$MAJOR.$MINOR.$PATCH 134*a24ffb47SSadaf Ebrahimi $ git push upstream v$MAJOR.$MINOR.x 135*a24ffb47SSadaf Ebrahimi ``` 136*a24ffb47SSadaf Ebrahimi 137*a24ffb47SSadaf Ebrahimi## Deployment 138*a24ffb47SSadaf Ebrahimi 139*a24ffb47SSadaf EbrahimiDeployment to Maven Central (or the snapshot repo) is for all of the artifacts 140*a24ffb47SSadaf Ebrahimifrom the project. 141*a24ffb47SSadaf Ebrahimi 142*a24ffb47SSadaf Ebrahimi### Branch 143*a24ffb47SSadaf Ebrahimi 144*a24ffb47SSadaf EbrahimiBefore building/deploying, be sure to switch to the appropriate tag. The tag 145*a24ffb47SSadaf Ebrahimimust reference a commit that has been pushed to the main repository, i.e., has 146*a24ffb47SSadaf Ebrahimigone through code review. For the current release use: 147*a24ffb47SSadaf Ebrahimi 148*a24ffb47SSadaf Ebrahimi```bash 149*a24ffb47SSadaf Ebrahimi$ git checkout -b v$MAJOR.$MINOR.$PATCH tags/v$MAJOR.$MINOR.$PATCH 150*a24ffb47SSadaf Ebrahimi``` 151*a24ffb47SSadaf Ebrahimi 152*a24ffb47SSadaf Ebrahimi### Building and Deploying 153*a24ffb47SSadaf Ebrahimi 154*a24ffb47SSadaf EbrahimiThe following command will build the whole project and upload it to Maven 155*a24ffb47SSadaf EbrahimiCentral. Parallel building [is not safe during 156*a24ffb47SSadaf EbrahimiuploadArchives](https://issues.gradle.org/browse/GRADLE-3420). 157*a24ffb47SSadaf Ebrahimi 158*a24ffb47SSadaf Ebrahimi```bash 159*a24ffb47SSadaf Ebrahimi$ ./gradlew clean build && ./gradlew -Dorg.gradle.parallel=false uploadArchives 160*a24ffb47SSadaf Ebrahimi``` 161*a24ffb47SSadaf Ebrahimi 162*a24ffb47SSadaf EbrahimiIf the version has the `-SNAPSHOT` suffix, the artifacts will automatically go 163*a24ffb47SSadaf Ebrahimito the snapshot repository. Otherwise it's a release deployment and the 164*a24ffb47SSadaf Ebrahimiartifacts will go to a staging repository. 165*a24ffb47SSadaf Ebrahimi 166*a24ffb47SSadaf EbrahimiWhen deploying a Release, the deployment will create [a new staging 167*a24ffb47SSadaf Ebrahimirepository](https://oss.sonatype.org/#stagingRepositories). You'll need to look 168*a24ffb47SSadaf Ebrahimiup the ID in the OSSRH UI (usually in the form of `opencensus-*`). 169*a24ffb47SSadaf Ebrahimi 170*a24ffb47SSadaf Ebrahimi## Releasing on Maven Central 171*a24ffb47SSadaf Ebrahimi 172*a24ffb47SSadaf EbrahimiOnce all of the artifacts have been pushed to the staging repository, the 173*a24ffb47SSadaf Ebrahimirepository must first be `closed`, which will trigger several sanity checks on 174*a24ffb47SSadaf Ebrahimithe repository. If this completes successfully, the repository can then be 175*a24ffb47SSadaf Ebrahimi`released`, which will begin the process of pushing the new artifacts to Maven 176*a24ffb47SSadaf EbrahimiCentral (the staging repository will be destroyed in the process). You can see 177*a24ffb47SSadaf Ebrahimithe complete process for releasing to Maven Central on the [OSSRH 178*a24ffb47SSadaf Ebrahimisite](http://central.sonatype.org/pages/releasing-the-deployment.html). 179*a24ffb47SSadaf Ebrahimi 180*a24ffb47SSadaf Ebrahimi## Announcement 181*a24ffb47SSadaf Ebrahimi 182*a24ffb47SSadaf EbrahimiOnce deployment is done, go to Github [release 183*a24ffb47SSadaf Ebrahimipage](https://github.com/census-instrumentation/opencensus-java/releases), press 184*a24ffb47SSadaf Ebrahimi`Draft a new release` to write release notes about the new release. 185*a24ffb47SSadaf Ebrahimi 186*a24ffb47SSadaf EbrahimiYou can use `git log upstream/v$MAJOR.$((MINOR-1)).x..upstream/v$MAJOR.$MINOR.x --graph --first-parent` 187*a24ffb47SSadaf Ebrahimior the Github [compare tool](https://github.com/census-instrumentation/opencensus-java/compare/) 188*a24ffb47SSadaf Ebrahimito view a summary of all commits since last release as a reference. In addition, you can refer to 189*a24ffb47SSadaf Ebrahimi[CHANGELOG.md](https://github.com/census-instrumentation/opencensus-java/blob/master/CHANGELOG.md) 190*a24ffb47SSadaf Ebrahimifor a list of major changes since last release. 191*a24ffb47SSadaf Ebrahimi 192*a24ffb47SSadaf EbrahimiPlease pick major or important user-visible changes only. 193*a24ffb47SSadaf Ebrahimi 194*a24ffb47SSadaf Ebrahimi## Update release versions in documentations and build files 195*a24ffb47SSadaf Ebrahimi 196*a24ffb47SSadaf EbrahimiAfter releasing is done, you need to update all readmes and examples to point to the 197*a24ffb47SSadaf Ebrahimilatest version. 198*a24ffb47SSadaf Ebrahimi 199*a24ffb47SSadaf Ebrahimi1. Update README.md and gradle/maven build files on `master` branch: 200*a24ffb47SSadaf Ebrahimi 201*a24ffb47SSadaf Ebrahimi```bash 202*a24ffb47SSadaf Ebrahimi$ git checkout -b bump-document-version master 203*a24ffb47SSadaf Ebrahimi$ BUILD_FILES=( 204*a24ffb47SSadaf Ebrahimi examples/build.gradle 205*a24ffb47SSadaf Ebrahimi examples/pom.xml 206*a24ffb47SSadaf Ebrahimi ) 207*a24ffb47SSadaf Ebrahimi$ README_FILES=( 208*a24ffb47SSadaf Ebrahimi README.md 209*a24ffb47SSadaf Ebrahimi contrib/appengine_standard_util/README.md 210*a24ffb47SSadaf Ebrahimi contrib/dropwizard/README.md 211*a24ffb47SSadaf Ebrahimi contrib/dropwizard5/README.md 212*a24ffb47SSadaf Ebrahimi contrib/exemplar_util/README.md 213*a24ffb47SSadaf Ebrahimi contrib/grpc_util/README.md 214*a24ffb47SSadaf Ebrahimi contrib/http_jaxrs/README.md 215*a24ffb47SSadaf Ebrahimi contrib/http_jetty_client/README.md 216*a24ffb47SSadaf Ebrahimi contrib/http_servlet/README.md 217*a24ffb47SSadaf Ebrahimi contrib/http_util/README.md 218*a24ffb47SSadaf Ebrahimi contrib/log_correlation/log4j2/README.md 219*a24ffb47SSadaf Ebrahimi contrib/log_correlation/stackdriver/README.md 220*a24ffb47SSadaf Ebrahimi contrib/spring/README.md 221*a24ffb47SSadaf Ebrahimi contrib/spring_sleuth_v1x/README.md 222*a24ffb47SSadaf Ebrahimi contrib/zpages/README.md 223*a24ffb47SSadaf Ebrahimi exporters/stats/prometheus/README.md 224*a24ffb47SSadaf Ebrahimi exporters/stats/signalfx/README.md 225*a24ffb47SSadaf Ebrahimi exporters/stats/stackdriver/README.md 226*a24ffb47SSadaf Ebrahimi exporters/trace/datadog/README.md 227*a24ffb47SSadaf Ebrahimi exporters/trace/elasticsearch/README.md 228*a24ffb47SSadaf Ebrahimi exporters/trace/instana/README.md 229*a24ffb47SSadaf Ebrahimi exporters/trace/logging/README.md 230*a24ffb47SSadaf Ebrahimi exporters/trace/jaeger/README.md 231*a24ffb47SSadaf Ebrahimi exporters/trace/ocagent/README.md 232*a24ffb47SSadaf Ebrahimi exporters/trace/stackdriver/README.md 233*a24ffb47SSadaf Ebrahimi exporters/trace/zipkin/README.md 234*a24ffb47SSadaf Ebrahimi ) 235*a24ffb47SSadaf Ebrahimi# Substitute versions in build files 236*a24ffb47SSadaf Ebrahimi$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*LATEST_OPENCENSUS_RELEASE_VERSION\)/'$MAJOR.$MINOR.$PATCH'\1/' \ 237*a24ffb47SSadaf Ebrahimi "${BUILD_FILES[@]}" 238*a24ffb47SSadaf Ebrahimi# Substitute versions in build.gradle examples in README.md 239*a24ffb47SSadaf Ebrahimi$ sed -i 's/\(\(compile\|runtime\).\+io\.opencensus:.\+:\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1'$MAJOR.$MINOR.$PATCH'/' \ 240*a24ffb47SSadaf Ebrahimi "${README_FILES[@]}" 241*a24ffb47SSadaf Ebrahimi# Substitute versions in maven pom examples in README.md 242*a24ffb47SSadaf Ebrahimi$ sed -i 's/\(<version>\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1'$MAJOR.$MINOR.$PATCH'/' \ 243*a24ffb47SSadaf Ebrahimi "${README_FILES[@]}" 244*a24ffb47SSadaf Ebrahimi$ git commit -a -m "Update release versions for all readme and build files." 245*a24ffb47SSadaf Ebrahimi``` 246*a24ffb47SSadaf Ebrahimi 247*a24ffb47SSadaf Ebrahimi2. Go through PR review and merge it to GitHub master branch. 248*a24ffb47SSadaf Ebrahimi 249*a24ffb47SSadaf Ebrahimi3. In addition, create a PR to mark the new release in 250*a24ffb47SSadaf Ebrahimi[CHANGELOG.md](https://github.com/census-instrumentation/opencensus-java/blob/master/CHANGELOG.md) 251*a24ffb47SSadaf Ebrahimion master branch. Once that PR is merged, cherry-pick the commit and create another PR to the 252*a24ffb47SSadaf Ebrahimirelease branch (branch v$MAJOR.$MINOR.x). 253*a24ffb47SSadaf Ebrahimi 254*a24ffb47SSadaf Ebrahimi## Patch Release 255*a24ffb47SSadaf EbrahimiAll patch releases should include only bug-fixes, and must avoid adding/modifying the public APIs. 256*a24ffb47SSadaf EbrahimiTo cherry-pick one commit use the following command: 257*a24ffb47SSadaf Ebrahimi```bash 258*a24ffb47SSadaf Ebrahimi$ COMMIT=1224f0a # Set the right commit hash. 259*a24ffb47SSadaf Ebrahimi$ git cherry-pick -x $COMMIT 260*a24ffb47SSadaf Ebrahimi``` 261*a24ffb47SSadaf Ebrahimi 262*a24ffb47SSadaf Ebrahimi## Known Issues 263*a24ffb47SSadaf Ebrahimi 264*a24ffb47SSadaf Ebrahimi### Deployment for tag v0.5.0 265*a24ffb47SSadaf EbrahimiTo rebuild the releases on the tag v0.5.0 use: 266*a24ffb47SSadaf Ebrahimi```bash 267*a24ffb47SSadaf Ebrahimi$ ./gradlew clean build && ./gradlew uploadArchives 268*a24ffb47SSadaf Ebrahimi``` 269*a24ffb47SSadaf Ebrahimi 270*a24ffb47SSadaf EbrahimiIf option `-Dorg.gradle.parallel=false` is used, you will hit [this bug](https://issues.sonatype.org/browse/OSSRH-19485) 271*a24ffb47SSadaf Ebrahimicaused by [this bug](https://github.com/gradle/gradle/issues/1827) in gradle 3.5. 272