-
Notifications
You must be signed in to change notification settings - Fork 3
/
version.sbt
51 lines (45 loc) · 1.45 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ThisBuild / dynverVTagPrefix := false
ThisBuild / version := {
val Stable = """([0-9]+)\.([0-9]+)\.([0-9]+)(|-RC[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, patch, rc) <- Stable.unapplySeq(previousVer)
nextPatch <- scala.util.Try(patch.toInt).map(_ + 1).toOption
nextRc = {
if (rc startsWith "-RC") {
scala.util
.Try(rc.stripPrefix("-RC").toInt)
.map(_ + 1)
.toOption
} else {
Option.empty[Int]
}
}
} yield {
nextRc match {
case Some(nrc) =>
s"${maj}.${min}.${patch}-RC${nrc}-SNAPSHOT"
case _ =>
s"${maj}.${min}.${nextPatch}-SNAPSHOT"
}
}).getOrElse {
println("Fails to determine qualified snapshot version")
previousVer
}
current
}
case _ =>
sys.error("Fails to determine previous stable version")
}
} else {
descr.ref.value
}
}
case _ =>
sys.error("Fails to resolve Git information")
}
}