forked from Cryptonomic/Conseil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publishing.sbt
93 lines (80 loc) · 3.39 KB
/
publishing.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//add build information as an object in code
enablePlugins(BuildInfoPlugin)
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, git.gitHeadCommit)
buildInfoPackage := "tech.cryptonomic.conseil"
//uses git tags to generate the project version
//see https://github.com/sbt/sbt-git#versioning-with-git
enablePlugins(GitVersioning)
/* The versioning scheme is
* - use a major number as the platform version
* - add a date reference in form of yyww (year + week in year)
* - use the latest git tag formatted as "<anything>-release-<xyz>[-optionally-anything-else]" and take the numbers from xyz, increasing it
* Compose the three separated by "dots" to have the version that will be released
* The Git plugin will add a trailing "-SNAPSHOT" if there are locally uncommitted changes
*/
val majorVersion = 0
/* This allows to extract versions from past tags, not directly applied to
* the current commit
*/
git.useGitDescribe := true
//defines how to extract the version from git tagging
git.gitTagToVersionNumber := { tag: String =>
if (Versioning.releasePattern.findAllIn(tag).nonEmpty)
Some(Versioning.generate(major = majorVersion, date = java.time.LocalDate.now, tag = tag))
else
None
}
//custom task to create a new release tag
lazy val prepareReleaseTag = taskKey[String]("Use the current version to define a git-tag for a new release")
prepareReleaseTag := Versioning.prepareReleaseTagDef.value
//read the command details for a description
lazy val gitTagCommand =
Command.command(
name = "gitTag",
briefHelp = "will run the git tag command based on conseil versioning policy",
detail = """ A command to call the "git tag" commands (from sbt-git) with custom args.
| Allows any automated environment (e.g. jenkins, travis) to call
| "sbt gitTag" when a new release has been just published, bumping the versioning tag,
| ready for pushing to the git repo.
| In turn, sbt will pick the newly-minted tag for the new version definition.
""".stripMargin
) { state =>
val extracted = Project.extract(state)
val (state2, tag) = extracted.runTask(prepareReleaseTag, state)
//we might want to check out only for non-snapshots?
println(s"About to tag the new release as '$tag'")
//we might want to read the message from the env or from a local file
val command = s"""git tag -a -m "release tagged using sbt gitTag" $tag"""
Command.process(command, state2)
}
ThisBuild / commands += gitTagCommand
useGpg := true
//sonatype publishing keys
sonatypeProfileName := "tech.cryptonomic"
organization := "tech.cryptonomic"
organizationName := "Cryptomonic"
organizationHomepage := Some(url("https://cryptonomic.tech/"))
scmInfo := Some(
ScmInfo(
url("https://github.com/Cryptonomic/Conseil"),
"scm:[email protected]:Cryptonomic/Conseil.git"
)
)
//should fill this up with whoever needs to appear there
developers := List(
Developer(
id = "Cryptonomic",
name = "Cryptonomic Inc",
email = "[email protected]",
url = url("https://cryptonomic.tech/")
)
)
description := "Query API for the Tezos blockchain."
licenses := List("gpl-3.0" -> new URL("https://www.gnu.org/licenses/gpl-3.0.txt"))
homepage := Some(url("https://cryptonomic.tech/"))
// Remove all additional repository other than Maven Central from POM
pomIncludeRepository := { _ =>
false
}
publishMavenStyle := true
publishTo := sonatypePublishTo.value