-
Notifications
You must be signed in to change notification settings - Fork 5
/
version.sbt
35 lines (30 loc) · 1010 Bytes
/
version.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
ThisBuild / dynverVTagPrefix := false
ThisBuild / version := {
val Stable = """([0-9]+)\.([0-9]+)\.([0-9]+)""".r
(ThisBuild / dynverGitDescribeOutput).value match {
case Some(descr) => {
if ((ThisBuild / isSnapshot).value) {
(ThisBuild / previousStableVersion).value match {
case Some(previousVer) => {
val current = (for {
Seq(maj, min, _) <- Stable.unapplySeq(previousVer)
nextMinor <- scala.util.Try(min.toInt).map(_ + 1).toOption
} yield {
val suffix = descr.commitSuffix.sha
s"${maj}.${nextMinor}.0-${suffix}-SNAPSHOT"
}).getOrElse {
sys.error("Fails to determine qualified snapshot version")
}
current
}
case _ =>
sys.error("Fails to determine previous stable version")
}
} else {
descr.ref.value
}
}
case _ =>
sys.error("Fails to resolve Git information")
}
}