Skip to content
Gradle plugin for versioning projects based on semantic versioning via git tags.
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

👻 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.0.0'

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
    branches { list of branch configurations
        branch {
            regex = ".+" regex for the branch you want to configure
            incrementer = "NO_VERSION_INCREMENTER" (default) version incrementer
            formatter = { "${}.${}.${}+build.${}.sha.${}" } (default) version formatting closure


The versions have to be stored as annotated 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

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.

  • If the current commit has an annotated tag this tag will be the version.
  • If the current commit has no annotated 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 annotated 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 annotated 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)

You can’t perform that action at this time.