-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.sbt
59 lines (51 loc) · 1.61 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
52
53
54
55
56
57
58
59
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) {
val previous = descr.ref match {
case r @ sbtdynver.GitRef(tag) if r.isTag =>
Some(tag)
case _ =>
(ThisBuild / previousStableVersion).value
}
previous 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")
}
}