Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

👻 semver-git-plugin

Version your gradle projects with git tags and semantic versioning.

GitHub version License Build Status codecov

Apply the plugin

Gradle 2.1 and higher

plugins {

Gradle 1.x and 2.0

buildscript {
   repositories {
      maven {
         url ""
   dependencies {
      classpath 'io.wusa:semver-git-plugin:2.3.7'

apply plugin: 'io.wusa.semver-git-plugin'

Configure the plugin

semver {
    snapshotSuffix = "SNAPSHOT" // (default) appended if the commit is without a release tag
    dirtyMarker = "dirty" // (default) appended if the are uncommitted changes
    initialVersion = "0.1.0" // (default) initial version in semantic versioning
    tagPrefix = "" // (default) each project can have its own tags identified by a unique prefix.
    tagtype = TagType.Annotated // (default) options are Annotated or Lightweight
    branches { // list of branch configurations
        branch {
            regex = ".+" // regex for the branch you want to configure, put this one last
            incrementer = "NO_VERSION_INCREMENTER" // (default) version incrementer
            formatter = { "${}.${}.${}+build.${}.sha.${}" } // (default) version formatting closure

Use with a Gradle multi-module project

For projects which take advantage of Gradle's multi-module projects, it is possible to specify different tags for each module.

The tags for each module must be distinguished with an unambiguous prefix. For example, if you have three modules foo, bar, and blega, you may consider using the module name as the prefix. This prefix is configured in the semver configuration block:

semver {
  tagPrefix = "foo-"

Given the above configuration, the tags for the "foo" module must all begin with "foo-"; e.g., "foo-3.2.6", etc... Note that besides the prefix, the rules for the tag names must still follow all the same semver rules as apply in any other case.


Incrementer Description
NO_VERSION_INCREMENTER Doesn't increment the version at all.
PATCH_INCREMENTER Increments the patch version by one.
MINOR_INCREMENTER Increments the minor version by one.
MAJOR_INCREMENTER Increments the major version by one.
CONVENTIONAL_COMMITS_INCREMENTER Increments the version according to conventional commits.


The versions have to be stored as annotated or lightweight (depending on the configured tag type) git tags in the format of semantic versioning.

To create a new annotated release tag:

git tag -a 1.0.0-alpha.1 -m "new alpha release of version 1.0.0"
git push --tags

To create a new lightweight release tag:

git tag -a 1.0.0-alpha.1
git push --tags

Following commits without a release tag will have the snapshotSuffix (default SNAPSHOT) appended and the version number bumped according to incrementer (default minor) strategy, e.g., 1.1.0-alpha.1-SNAPSHOT.

Version usage

Then you can access the version of your project via


allprojects {
    version =
project.version =

Version information

Access the following information via* e.g.,

Property Description Git: master Git: feature/ghosty Group of the branch master feature Name of the branch master feature/ghosty Tokenized branch name master feature-ghosty
info.commit Full sha1 commit hash 4ecabe2e8646fd0b577dcda83e5c23447e230496 4ecabe2e8646fd0b577dcda83e5c23447e230496
info.shortCommit Short sha1 commit has d2459d d2459d
info.tag Current tag If any name of the tag else none If any name of the tag else none
info.lastTag Last tag If any name of the tag else none If any name of the tag else none
info.dirty Current state of the working copy true if the working copy contains uncommitted files true if the working copy contains uncommitted files
info Formatted version 0.1.0 0.1.0
info.version.major Major version of 2.0.0-rc.1+build.123 2 2
info.version.minor Minor version of 2.0.0-rc.1+build.123 0 0
info.version.patch Patch version of 2.0.0-rc.1+build.123 0 0 Build number of 2.0.0-rc.1+build.123 build.123 build.123
info.version.prerelease Pre release of 2.0.0-rc.1+build.123 rc.1 rc.1

Display version

The is based on the current or last tag (depending on the specified tag type).

  • If the current commit has an tag this tag will be the version.
  • If the current commit has no tag the version takes the last tag and builds the new version based on:
    • The ordering of the branch configuration is important for the matching.
  • If no tag exists the initial commit will be version 0.1.0 as recommended by Semantic Versioning 2.0.0. The following commits will be build based on this version until a tag is created.


The semver plugin offers two tasks.


Displays the version information:

> Task :showVersion
Version: 0.0.1


Displays the full info:

> Task :showInfo
Branch name: feature/test
Branch group: feature
Branch id: feature-test
Commit: fd132d87d51cee610c5b273050625850e1d62a3b
Short commit: fd132d8
Tag: none
Last tag: 0.0.1
Dirty: false
Version: 0.1.0-SNAPSHOT
Version major: 0
Version minor: 1
Version patch: 0
Version pre release: none
Version build: none


The MIT License (MIT)