From af4fbf1cbd857ef0d04dec987ff4d3f492547766 Mon Sep 17 00:00:00 2001 From: Jannik Arndt Date: Thu, 23 Apr 2020 16:39:36 +0200 Subject: [PATCH] Use git tags for versioning --- build.sbt | 20 +++++++++++++++++++- project/plugins.sbt | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2c22fb0..f95cb7c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,6 @@ lazy val root = (project in file(".")) .settings( name := "scala-http-client", organization := "io.moia", - version := "1.3.1", licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0")), scmInfo := Some(ScmInfo(url("https://github.com/moia-dev/scala-http-client"), "scm:git@github.com:moia-dev/scala-http-client.git")), homepage := Some(url("https://github.com/moia-dev/scala-http-client")), @@ -24,6 +23,11 @@ lazy val root = (project in file(".")) Defaults.itSettings, scalacOptions in IntegrationTest := (scalacOptions in Compile).value.filterNot(_ == "-Ywarn-dead-code") ) + .settings(sbtGitSettings) + .enablePlugins( + GitVersioning, + GitBranchPrompt + ) val akkaVersion = "2.6.4" val akkaHttpVersion = "10.1.11" @@ -93,3 +97,17 @@ lazy val sonatypeSettings = { credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential") ) } + +lazy val sbtVersionRegex = "v([0-9]+.[0-9]+.[0-9]+)-?(.*)?".r + +lazy val sbtGitSettings = Seq( + git.useGitDescribe := true, + git.baseVersion := "0.0.0", + git.uncommittedSignifier := None, + git.gitTagToVersionNumber := { + case sbtVersionRegex(v, "") => Some(v) + case sbtVersionRegex(v, "SNAPSHOT") => Some(s"$v-SNAPSHOT") + case sbtVersionRegex(v, s) => Some(s"$v-$s-SNAPSHOT") + case _ => None + } +) diff --git a/project/plugins.sbt b/project/plugins.sbt index c87398a..df68439 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -15,3 +15,5 @@ addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2") // publishSigned addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") + +addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")