---
title: "How to add auto-update the Version Number of a Play Framework 2.X Project"
date: 2016-03-08T13:34:08+00:00
author: "poornerd"
canonical: https://www.poornerd.com/2016/03/08/how-to-add-auto-update-the-version-number-of-a-play-framework-2-x-project/
source: Raw Markdown twin of the HTML article; content is the original source.
---
I wanted to have Version numbers that get automatically updated when I want to release a new version, so I set about to find out how to do this with Play Framework.

I discovered that I could base it on the **sbt-release** plugin, but it was not so straight forward. Here is my strategy, so that in the end all I have to do is run &#8220;**`activator release`**&#8220;:

### 1. Add the Plugin

Add the plugin by adding this line to your `project/plugins.sbt` file:

<pre class="brush: plain; title: ; notranslate" title="">addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.2")</pre>

### 2. Update your build.sbt file:

Add this import near the top of the file:

<pre class="brush: plain; title: ; notranslate" title="">import ReleaseTransformations._
</pre>

Change the line with version to this:

<pre class="brush: plain; title: ; notranslate" title="">version := (version in ThisBuild).value
</pre>

Next optionally add this piece of code at the end and comment out the pipeline stages you do not want executed _(Note: this is apparently the default pipeline)_:

<pre class="brush: plain; title: ; notranslate" title="">releaseProcess := Seq[ReleaseStep](
  checkSnapshotDependencies,              // : ReleaseStep
  inquireVersions,                        // : ReleaseStep
  runTest,                                // : ReleaseStep
  setReleaseVersion,                      // : ReleaseStep
  commitReleaseVersion,                   // : ReleaseStep, performs the initial git checks
  tagRelease,                             // : ReleaseStep
  //publishArtifacts,                       // : ReleaseStep, checks whether `publishTo` is properly set up
  setNextVersion,                         // : ReleaseStep
  commitNextVersion                      // : ReleaseStep
  //pushChanges                             // : ReleaseStep, also checks that an upstream branch is properly configured
)
</pre>

_Note: I have commented out the automatic publish and git push_

### 3. Get the Version Number in a controller and pass to a template

<pre class="brush: plain; title: ; notranslate" title="">public static Result index() {
    String title = Application.class.getPackage().getImplementationTitle();  
    String version = Application.class.getPackage().getImplementationVersion();   
    return ok(index.render(version));
}
</pre>

And display it in the template:

<pre class="brush: plain; title: ; notranslate" title="">@(version: String)

...
Version: @version

</pre>

### 4. Make sure everything is committed before you release

### 5. Execute the release

Once you execute the release, the new version will be stored in a file **versions.sbt** .

<pre class="brush: plain; title: ; notranslate" title="">activator release

</pre>

You can lookup more options and possibilities for the **sbt-release** plugin, including strategies for auto incrementing the version here: <a href="https://github.com/sbt/sbt-release" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');" target="_blank">https://github.com/sbt/sbt-release</a>
