Search code examples
javagitmavensemantic-versioningjgitflow-maven-plugin

What's the right maven command for releasing from release branch to master with gitflow-maven-plugin?


I'm testing versioning in IntelliJ with gitflow-maven-plugin, I wanted to update major and minor manually:

mvn -B gitflow:release-start -DcommitDevelopmentVersionAtStart=true -DversionDigitToIncrement=0

After this command, a new release branch created, called 'release/1.0.14', now the develop branch verison in pom file is '1.1.0-SNAPSHOT'(which is what I want, it updates the minor, but I'm not sure why it's 1.0.14 in releasing branch), next step is to update to master branch, I tried:

-B gitflow:release-finish -DversionDigitToIncrement=0 -X

but it's not what I want, I guess the master will be updated to 1.0.14 first and 1.1.0 next? But after this command, the version in develop became 1.0.15-SNAPSHOT, not sure what's the right way to do this, any thoughts would be appreciated.


Solution

  • Gitflow defines two permanent branches (master and develop). The master branch contains a production ready version (a released version). If you start a release your current code base from develop is used to create to release/x.y.z branch and when you finish your release the release/x.y.z branch is merged back to master and also develop.

    The version update is done in the goal: release-start and you can influence the order in which the develop branch is updated with: commitDevelopmentVersionAtStart

    e.g. Version in pom.xml on branch development is 1.0.14-SNAPSHOT if you now perform:

    mvn gitflow:release-start -B -DversionDigitToIncrement=1 -DcommitDevelopmentVersionAtStart=true 
    

    You should end up with a new release branch release/1.0.14 having version 1.0.14 and the version in you pom.xml on branch development is updated to 1.1.0-SNAPSHOT the version on master is not updated (yet). To "update" the version on master you need to finish the release.


    I kind of misunderstood your question - therefor I've added also this part which you've asked in an other question.

    Have a look at the docu at: gitflow-maven-plugin (search for: versionDigitToIncrement)

    The gitflow:release-finish and gitflow:release goals have versionDigitToIncrement parameter which controls which digit to increment in the next development version. Starts from zero. For example, if the release version is 1.2.3.4 and versionDigitToIncrement is set to 1 then the next development version will be 1.3.0.0-SNAPSHOT. If not set or set to not valid value defaults to increment last digit in the version.

    Comming from 1.0.14-SNAPSHOT:

    • versionDigitToIncrement: 0 updates the major version on development to 2.0.0-SNAPSHOT.
    • versionDigitToIncrement: 1 updates the major version on development to 1.1.0-SNAPSHOT.
    • versionDigitToIncrement: 2 updates the major version on development to 1.0.15-SNAPSHOT.

    But it seems that the -DversionDigitToIncrement passed on the cli is ignored. Setting it in the configuration area in your pom.xml leads to the expected results.

    <plugin>
      <groupId>com.amashchenko.maven.plugin</groupId>
      <artifactId>gitflow-maven-plugin</artifactId>
      <version>1.14.0</version>
      <configuration>
        <versionDigitToIncrement>1</versionDigitToIncrement>
      </configuration>
    </plugin>