sbt-git-flow-version announcement

Posted on November 13, 2018

I’d like to announce my new project called sbt-git-flow-version. As you might guess it’s a plugin for sbt. The goal of the project is set your sbt build version according to git flow rules.

I found that for big or medium size teams git flow is quite practical. What I didn’t like about it, is that it requires to change the version all the time you change the branch in your repository. At some point I took responsibilities of release engineer in our team. Since I’m very lazy to do all of this styff I came up with some Scala code in the project catalog of my current working project. Later I rewrote it as an sbt plugin.

So, what can it do for you?

Let’s start with git flow. The typical git flow process have following branches:

You might see that we need three components to compose the version:

The main setting of sbt-git-flow-version is versionPolicy which has type Seq[(BranchMatcher => VersionCalculator)]. So it tries to find matching rule for a branch and calculate a version.

What is a BranchMatcher? It’s a function String => Option[Matching] where matching is a case class containing branch name and some additional optional extracted string. There are several predefined branch matchers:

The VersionCalculator converts previous version, current version, and matching either to the version number or error message. The predefined version calculators are:

The default policy is defined as:

What literally means following:

You can define your own rules in you build.sbt in the following way:

import sbtgitflowversion.BranchMatcher._
import sbtgitflowversion.VersionCalculator._

versionPolicy := (exact("big-release") -> next-major()) +: versionPolicy.value

This will set the next major version for the “big-release” branch.

Current verion of the plugin is 0.1. So, to add to your project/plugins.sbt the line:

addSbtPlugin("me.limansky" % "sbt-git-flow-version" % "0.1")

Recent posts

Tag cloud

Akka BeanPurée DSL Gentoo Hakyll Haskell Java NVidia Scala Spray XMonad collections git sbt sbt-git-flow-version shapeless