Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version numbering / release mechanics with Maven and GitHub

I'm trying to work out the optimal way of managing my workflow to allow version numbering and releases with Maven and Git.

Currently my workflow is:

  1. Edit pom.xml to indicate a new snapshot version "1.2.3-SNAPSHOT"
  2. Commit to git with message "start work on 1.2.3-SNAPSHOT"
  3. Do coding work, commit after each successful "mvn test" etc.
  4. Once happy with version, edit pom.xml version to "1.2.3"
  5. Commit with message "1.2.3 Release"
  6. Add a tag "1.2.3"
  7. Deploy the code (e.g. push to an external Maven repository)
  8. GOTO 1.

I do all the work in the "master" branch unless I need to do something experimental (in which case I switch to a new branch, merging periodically)

Is this a sensible workflow? Any ways that I could improve it.

like image 895
mikera Avatar asked Aug 30 '12 02:08

mikera


1 Answers

Use the maven-release plugin which is supposed to do that for you. Releases involve two steps:

  • mvn release:prepare which will ask you for the released version, tag name, and next development version
  • mvn release:perform which will build the release artifacts and publish them on a remote maven repository

To make this work, you have to configure in your pom file several things:

  • proper SCM URLs, which for GitHub should look like:
  <scm>
    <connection>scm:git:git://github.com/user/repo.git</connection>
    <developerConnection>scm:git:[email protected]:user/repo.git</developerConnection>
    <url>https://github.com/user/repo/tree/master/</url>
  </scm>
  • proper distribution repositories where release:perform will upload the built artifacts

While you're at it, you should set up a GPG key that should be used for signing tags.

like image 66
Sergiu Dumitriu Avatar answered Sep 30 '22 17:09

Sergiu Dumitriu