Skip to content

Release Process (Java)

Aindriunannerb edited this page Jan 16, 2020 · 34 revisions

a few notes from maven release process

Requirements

  • Have gpg-agent installed, configured and running. One way to be sure to check if your gpg agent is running correctly is to encrypt and decrypt a file, using the gpg tool, don't forget to pass the --use-agent option, you should be prompted with a dialog (depending on your OS asking for your pass phrase). Now try to decrypt again, you should not be asked again for your pass phrase : your agent is working.
gpg --output doc.gpg --encrypt --recipient corinnekrych@gmail.com doc.txt
gpg --output doc2.txt --decrypt doc.gpg 

where doc.txt == doc2.txt

File content should be the same.

  • Have a JBoss Nexus account (the same as your JBoss JIRA account).

Setup

  • Add your gpg secret key id to your global git config : git config --global user.signingkey YOURKEYID

  • Set up the password encryption for Maven, you can follow these instructions : http://maven.apache.org/guides/mini/guide-encryption.html , make sure to use your JBoss Nexus credentials for these steps.

  • Configure the JBoss Nexus repositories in your settings.xml , these ones should be added

<profile>
   <id>jboss-public-repository</id>
   <repositories>
      <repository>
         <id>jboss-public-repository-group</id>
         <name>JBoss Public Maven Repository Group</name>
         <url>http://repository.jboss.org/nexus/content/groups/public/</url>
         <layout>default</layout>
         <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </releases>
         <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </snapshots>
      </repository>
      <repository>
         <id>jboss-public-snapshot-repository-group</id>
         <name>JBoss Public Maven Repository Group</name>
         <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
         <layout>default</layout>
         <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </releases>
         <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </snapshots>
      </repository>
      <repository>
         <id>jboss-staging-aerogear-repository</id>
         <name>JBoss Staging repository</name>
         <url>https://repository.jboss.org/nexus/content/repositories/jboss_releases_staging_profile-1068</url>
         <layout>default</layout>
         <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </releases>
         <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </snapshots>
      </repository>
   </repositories>
   <pluginRepositories>
      <pluginRepository>
         <id>jboss-public-repository-group</id>
         <name>JBoss Public Maven Repository Group</name>
         <url>http://repository.jboss.org/nexus/content/groups/public/</url>
         <layout>default</layout>
         <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </releases>
         <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
         </snapshots>
      </pluginRepository>
   </pluginRepositories>
</profile>
  • Encrypt your passwords:

(optional) Release snapshots

You can skip with step. Let's test this set up by releasing a snapshot :

mvn gpg:sign-and-deploy-file \
    -Dfile=target/my-artifact-to-be-released-x.y.z-SNAPSHOT.jar \
    -Durl=https://repository.jboss.org/nexus/content/repositories/snapshots/ \
    -DpomFile=pom.xml \
    -DrepositoryId=jboss-public-snapshots-repository

This tests two things:

  • upload to the nexus repository works
  • your GPG settings are working and you are able to sign the artifacts

You can delete the uploaded artifacts if you do not want to make them publicly available. Log into Nexus and click on "Repositories" and then choose "JBoss Snapshots" in the list of repositories listed. You can then drill down to the package structure to the artifact you want to delete.

Release process

  1. mvn release:prepare

     mvn release:prepare -Dtag=tag
    

NOTE: The tag should only be the version number like mvn release:prepare -Dtag=0.2.21 If you have a multi-module project can use -DautoVersionSubmodules=true

The release plugin does lots of thing for you like bumping to the next snapshot version and checking files, you can do a git status and check the differences.

  1. Sign the Git tag :
    • Delete the tag : git tag -d x.y.z

    • Recreate the tag signing it : git tag -s x.y.z <commit_SHA_of_the_prepare_release> -m "signed MY ARTIFACT x.y.z tag"

    • Make sure you signed the correct commit commit

    • Verify that you really singed the tag, by executing git tag -v x.y.z. The output should be similar to:

      object ac05cd2a4ed8b6ef354acdf17fff321f33548997 type commit tag 0.2.1 tagger Matthias Wessendorf matzew@apache.org 1375864277 +0200

      signed unified push java client 0.2.1 tag gpg: Signature made Wed Aug 7 10:31:17 2013 CEST using DSA key ID 1CE17EDC gpg: Good signature from "Matthias Wessendorf matzew@apache.org"

    • If all went OK, push the tag

    • (Optional) Go to your github profile page and add or make sure you GPG public key is added. Going to release tab you will show a Verified label.

git push origin 0.2.21   

where 0.2.21 is the release tag. Note: The delete and recreate tasks are a workaround of this bug .

Note 2: You don't need to push the changes on master, only the tag. (already tested)

  1. Run Maven perform

     MAVEN_OPTS="-DperformRelease=true -Dgpg.useagent=true" mvn release:perform
    
  2. Push the changes performed by maven plugin

     git push origin master   
    

Note 2: You only want to do this once your staging time has ended and tests have been successful.

  1. Stage on Nexus

Go to the staging repository and check if the artifact was corrected uploaded

nexus screenshot

Close the repository to stage ("close" could sound confusing but in fact it means your repository will be staged).

stage

Refresh and communicate on the mailing list the repository URL

Be sure to have git-extras installed, this way you can easily generate a change log by running git changelog , that will create an history.md file containing your changelog.

In the body of your email make sure to mention :

  • The new version that has been released
  • The staging repo location
  • The changelog

(http://photon.abstractj.org/Sonatype_Nexus_Professional_20130731_085648.jpg)

  1. Doing the real release

After 72 hours, if no feedback is provided (lazy consensus). The artifact will be literary released. To do that just push this button :

release

For nexus to synchronize with maven central repo it can takes up to 2 days. Search for your release in maven central.

Clone this wiki locally