Performing a Release - robolectric/robolectric GitHub Wiki

Preparation

  1. In order to sign release artifacts, you will need to have access to the Robolectric GPG key. Ask a Robolectric maintainer for the Robolectric key. Once you have it, run:

    gpg --import robolectric.asc
    

    This will prompt you for the key password (ask an existing Robolectric maintainer what this is).

  2. Gradle artifact signing requires the legacy secring.gpg file, which is not generated any more when running v2.1+ of GnuPG. If you have not already done this, you will need to export it using:

    gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg
    

    This will prompt you for your user password.

  3. Once you have imported the gpg signing keys, ensure that you have signing and release credentials in your ~/.gradle/gradle.properties. You can ask a Robolectric maintainer what the password and sonatype login is.

    signing.keyId=B408DBD5
    signing.password=********
    signing.secretKeyRingFile=/home/_____/.gnupg/secring.gpg
    systemProp.sonatype-login=********
    systemProp.sonatype-password=********
    
  4. You may want to check if the google branch is ahead of the master branch and if there are any commits you would like to include in the release. Releases are performed from the master branch.

Release

[!IMPORTANT] None of these instructions require a force-push. If you find yourself needing a force push, something went wrong, and you should reset and start over.

[!IMPORTANT] Never release anything (to either MavenCentral or the git push commands) until the release has been validated using the MavenCentral staging repository.

  1. Ensure that you are on the latest master branch of the GitHub repository.

    git fetch origin
    git checkout master
    git pull
    

    If there are errors, it usually means you have extra commits in the master branch, and you should either save those commits in a new branch, or do git checkout master && git reset --hard origin/master.

  2. Ensure that a release branch has been created. For instance, for 4.2.x releases, ensure that the branch exists:

    git checkout -b robolectric-4.2.x
    
  3. If the release branch already exists, ensure that it updated to the latest version

    git checkout robolectric-4.2.x
    git pull
    

    If there are errors, it usually means you have extra commits in the release branch, and you should either save those commits in a new branch, or do e.g. git checkout robolectric-4.2.x && git reset --hard origin/robolectric-4.2.x.

  4. Update the version number. Edit gradle.properties to remove -SNAPSHOT. Version strings look like 4.2 or 4.2-beta-1.

  5. Commit and tag the changes:

    versionNumber=___
    git commit -m "Bump version to $versionNumber."   
    
  6. Assemble all of the release artifacts:

    /gradlew clean assemble
    
  7. Run tests in your local workstation:

    ./gradlew test --parallel -Dorg.gradle.workers.max=4 -Drobolectric.alwaysIncludeVariantMarkersInTestName=true
    
  8. Upload the artifacts

    ./gradlew publish
    
  9. Log into Sonatype and close the staging repository.

  10. Use the staging repository URL to test the uploaded artifacts. Add this to your sample app's repositories section.

    maven {
        url "https://oss.sonatype.org/content/repositories/orgrobolectric-____"
    }
    
  11. Go to a sample Android app that contains a Robolectric test. Update the test dependencies to the new (staged) version. Validate that the release has the expected functionality. For instance, if the release supports a new SDK level, ensure that a test can run on that new SDK level.

    [!IMPORTANT] It is also important to verify that native functionality (e.g. SQLite and graphics) work on both Linux x86_64 and Mac M1.

  12. If everything has worked so far, it's time to actually release the artifacts!

    • Push the commits to the release branch

       git push origin robolectric-4.2.x
      

      [!IMPORTANT] If you encounter an error here, it means your release branch is outdated or contains extra commits. Reset and start over.

    • Tag the new version and push the tag

      git tag -a -m "Version $versionNumber" robolectric-$versionNumber
      git push origin robolectric-$versionNumber
      
    • Release the staging artifacts to MavenCentral.

  13. Wait for the new version to appear at Maven Central.

  14. Publish the GitHub release notes. Update the mailing list and Twitter account.

  15. Switch to the master branch. Ensure that the version number is bumped and contains the -SNAPSHOT suffix.

  16. If it is not, commit the new development version number:

    git commit -m "Bump version to <next version number>-SNAPSHOT."
    
  17. Bump docs and related projects to point at the latest version:

Update docs

  1. Assemble and aggregate Javadocs:

    ./gradlew clean aggregateDocs
    
  2. Add updated javadoc and jsondoc to the robolectric.github.io repository:

    docRepo=../robolectric.github.io
    docVersion=__
    mv build/docs/javadoc $docRepo/docs/javadoc/$docVersion
    
  3. Update robolectric.github.io's mkdocs.yml to add new version to the sidebar, and update latest version information. Search Javadoc to find the place to modify.

  4. ln -sfn $docVersion docs/javadoc/latest