Skip to content
🤔 Documentation issue? Report or edit

Releasing LeakCanary

Preparing the release environment

Set up your Sonatype OSSRH account

  • Create a Sonatype OSSRH JIRA account.
  • Create a ticket to request access to the com.squareup.leakcanary project. Here’s an example: OSSRH-54959.
  • Then ask someone with deployer role from the LeakCanary team to confirm access.

Set up your signing key

# Create a new key
gpg --gen-key
# List local keys. Key id is last 8 characters
gpg -K
cd ~/.gnupg
# Export key locally
gpg --export-secret-keys -o secring.gpg
# Upload key to Ubuntu servers
gpg --send-keys --keyserver <KEY ID>
# Confirm the key can now be found
gpg --recv-keys --keyserver <KEY ID>

Set up your home

Add this to your ~/.gradle/

signing.keyId=<KEY ID>
signing.password=<KEY PASSWORD>

Set up the Google Analytics docs key

Add this to your ~/.bashrc:


Set up GitHub CLI

Install GitHub CLI

brew install gh

Install jq, a CLI Json processor

brew install jq

Set up aliases for milestone management:

gh alias set listOpenMilestones "api graphql -F owner=':owner' -F name=':repo' -f query='
    query ListOpenMilestones(\$name: String\!, \$owner: String\!) {
        repository(owner: \$owner, name: \$name) {
            milestones(first: 100, states: OPEN) {
                nodes {

gh alias set --shell createMilestone "gh api --method POST repos/:owner/:repo/milestones --input - | jq '{ html_url: .html_url, state: .state, created_at: .created_at }'"

gh alias set --shell closeMilestone "echo '{\"state\": \"closed\"}' | gh api --method PATCH repos/:owner/:repo/milestones/\$1 --input - | jq '{ html_url: .html_url, state: .state, closed_at: .closed_at }'"

Install the doc generation dependencies

pip3 install mkdocs-material


  • Create a local release branch from main

    git checkout main
    git pull
    git checkout -b release_2.9

  • Update VERSION_NAME in (remove -SNAPSHOT)

    sed -i '' 's/VERSION_NAME=2.9-SNAPSHOT/VERSION_NAME=2.9/'

  • Update the current version and next version in mkdocs.yml

    sed -i '' 's/2.9/REPLACE_WITH_NEXT_VERSION_NUMBER/' mkdocs.yml
    sed -i '' 's/2.8.1/2.9/' mkdocs.yml

  • Generate the Dokka docs

    rm -rf docs/api
    ./gradlew leakcanary-android-core:dokka leakcanary-android-instrumentation:dokka leakcanary-android-process:dokka leakcanary-object-watcher-android:dokka leakcanary-object-watcher:dokka shark-android:dokka shark-graph:dokka shark-hprof:dokka shark-log:dokka shark:dokka plumber-android:dokka leakcanary-android-release:dokka

  • Update the changelog (commit list)

    mate docs/

  • Deploy the docs locally then open the changelog and check everything looks good

    mkdocs serve

  • Commit all local changes

    git commit -am "Prepare 2.9 release"

  • Perform a clean build

    ./gradlew clean
    ./gradlew build

  • Create a tag and push it

    git tag v2.9
    git push origin v2.9

  • Upload the artifacts to Sonatype OSS Nexus

    ./gradlew uploadArchives --no-daemon --no-parallel

  • Generate the CLI zip

    ./gradlew shark-cli:distZip

  • Release to Maven Central

    • Login to Sonatype OSS Nexus:
    • Click on Staging Repositories
    • Scroll to the bottom, you should see an entry named comsquareup-XXXX
    • Check the box next to the comsquareup-XXXX entry, click Close then Confirm
    • Wait a bit, hit Refresh, until the Status for that column changes to Closed.
    • Check the box next to the comsquareup-XXXX entry, click Release then Confirm
  • Merge the release branch to main
    git checkout main
    git pull
    git merge --no-ff release_2.9
  • Update VERSION_NAME in (increase version and add -SNAPSHOT)


  • Commit your changes

    git commit -am "Prepare for next development iteration"

  • Push your changes

    git push

  • Close the currently open milestone

    gh listOpenMilestones | jq '.data.repository.milestones.nodes[0].number' | xargs gh closeMilestone

  • Create a milestone for the new version

    echo '{
      "state": "open",
      "description": ""
    }' | gh createMilestone

  • Redeploy the docs

    mkdocs gh-deploy

  • Create a new release

    gh release create v2.9 ./shark-cli/build/distributions/ --title v2.9 --notes 'See [Change Log]('

  • Open the v2.9 release to confirm everything looks good.

  • Upload shark-cli to brew:

    brew bump-formula-pr --url leakcanary-shark

  • Wait for the release to be available on Maven Central.

  • Tell your friends, update all of your apps, and tweet the new release. As a nice extra touch, mention external contributions.