-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathVersion.scala
More file actions
20 lines (15 loc) · 809 Bytes
/
Version.scala
File metadata and controls
20 lines (15 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import scala.sys.process._
object Version {
def createVersion(baseVersion: String) = {
def getLastCommitFromGit = s"""git rev-parse --short HEAD""" !!
// either specify git hash as an env var or derive it
// if building from the hseeberger/scala-sbt docker image use env var
// (scala-sbt doesn't have git in it)
val lastCommit = sys.env.getOrElse("GIT_HASH", getLastCommitFromGit).trim()
val version = baseVersion + "-" + lastCommit
// The project isSnapshot string passed in via command line settings, if desired.
val isSnapshot = sys.props.getOrElse("project.isSnapshot", "true").toBoolean
// For now, obfuscate SNAPSHOTs from sbt's developers: https://github.com/sbt/sbt/issues/2687#issuecomment-236586241
if (isSnapshot) s"$version-SNAP" else version
}
}