-
Notifications
You must be signed in to change notification settings - Fork 76
/
version.sbt
37 lines (31 loc) · 1.18 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
// Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
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, patch) <- Stable.unapplySeq(previousVer)
nextPatch <- scala.util.Try(patch.toInt).map(_ + 1).toOption
} yield {
val suffix = descr.commitSuffix.sha
s"${maj}.${min}.${nextPatch}-${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 // without 'v' prefix
}
}
case _ =>
sys.error("Fails to resolve Git information")
}
}