summaryrefslogtreecommitdiff
path: root/build.sc
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-02-26 13:53:21 +0000
committerJuan J. Martinez <jjm@usebox.net>2021-07-22 19:49:49 +0100
commit43c68ba38f7dc33efdbf38b12fb11e8a3db7c031 (patch)
treec238a0f79a1eb9225fc045e45cd3996241b38dfd /build.sc
parenta14cafa19bb8b78722775fa3fee3b9987813d5b6 (diff)
downloadspacebeans-43c68ba38f7dc33efdbf38b12fb11e8a3db7c031.tar.gz
spacebeans-43c68ba38f7dc33efdbf38b12fb11e8a3db7c031.zip
BuildInfo support and smart version
Diffstat (limited to 'build.sc')
-rw-r--r--build.sc31
1 files changed, 30 insertions, 1 deletions
diff --git a/build.sc b/build.sc
index 69cc6f7..2209baf 100644
--- a/build.sc
+++ b/build.sc
@@ -2,7 +2,10 @@ import mill._
import mill.scalalib._
import scalafmt._
-object server extends ScalaModule with ScalafmtModule {
+import $ivy.`com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION`
+import mill.contrib.buildinfo.BuildInfo
+
+object server extends ScalaModule with ScalafmtModule with BuildInfo {
def scalaVersion = "2.13.5"
def scalacOptions = Seq(
@@ -30,6 +33,32 @@ object server extends ScalaModule with ScalafmtModule {
super.compile()
}
+ def gitHead = T.input { os.proc('git, "rev-parse", "HEAD").call().out.trim }
+
+ def getVersion = T.input {
+ val tag = try Option(
+ os.proc('git, 'describe, "--exact-match", "--tags", "--always", gitHead()).call().out.trim
+ )
+ catch { case e => None }
+
+ tag match {
+ case Some(t) => t
+ case None =>
+ val latestTaggedVersion = os.proc('git, 'describe, "--abbrev=0", "--always", "--tags").call().out.trim
+ val latestCommit = gitHead().take(6)
+ s"$latestTaggedVersion-$latestCommit"
+ }
+ }
+
+ val name = "spacebeans"
+ def buildInfoMembers: T[Map[String, String]] = T {
+ Map(
+ "name" -> name,
+ "version" -> getVersion()
+ )
+ }
+ def buildInfoPackageName = Some("net.usebox.gemini.server")
+
object test extends Tests with ScalafmtModule {
def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.2.2")
def testFrameworks = Seq("org.scalatest.tools.Framework")