-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_release.sbt
91 lines (77 loc) · 2.86 KB
/
build_release.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
import com.vdurmont.semver4j.Semver
import dev.quadstingray.sbt.json.JsonFile
import sbtrelease.ReleasePlugin.autoImport.ReleaseKeys.versions
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations.*
import sbtrelease.ReleasePlugin.runtimeVersion
import scala.sys.process.*
releaseVersionBump := sbtrelease.Version.Bump.NextStable
val gitAddAllTask = ReleaseStep(action = st => {
"git add .".!
st
})
val setToMyNextVersion = ReleaseStep(action = st => {
setMyVersion(st.get(versions).get._2, st)
st
})
val setToMyReleaseVersion = ReleaseStep(action = st => {
setMyVersion(st.get(versions).get._1, st)
st
})
def setMyVersion(version: String, state: State): Unit = {
state.log.warn(s"Set Version in package.json to $version")
val json = JsonFile(file("package.json"))
val newVersion = version.replace("-SNAPSHOT", ".snapshot")
json.updateValue("version", newVersion)
json.write()
}
releaseNextCommitMessage := s"ci: update version after release"
releaseCommitMessage := s"ci: prepare release of version ${runtimeVersion.value}"
commands += Command.command("ci-release")((state: State) => {
val semVersion = new Semver(version.value)
if (semVersion.isStable) {
Command.process("release with-defaults", state)
}
else {
state
}
})
releaseProcess := {
Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
setToMyReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
releaseStepCommand("ci-deploy-docs"),
setToMyNextVersion,
releaseStepCommand("scalafmt"),
gitAddAllTask,
commitNextVersion,
pushChanges
)
}
// add sonatype repository settings
// snapshot versions publish to sonatype snapshot repository
// other versions publish to sonatype staging repository
publishTo := sonatypePublishToBundle.value
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", System.getenv("SONATYPE_USER"), System.getenv("SONATYPE_PASSWORD"))
credentials += Credentials("New Sonatype Nexus Repository Manager", "s01.oss.sonatype.org", System.getenv("SONATYPE_USER"), System.getenv("SONATYPE_PASSWORD"))
Global / useGpgPinentry := true
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
packageOptions += {
Package.ManifestAttributes(
"Created-By" -> "Simple Build Tool",
"Built-By" -> "mongocamp",
"Build-Jdk" -> System.getProperty("java.version"),
"Specification-Title" -> name.value,
"Specification-Version" -> version.value,
"Specification-Vendor" -> organization.value,
"Implementation-Title" -> name.value,
"Implementation-Version" -> version.value,
"Implementation-Vendor-Id" -> organization.value,
"Implementation-Vendor" -> organization.value
)
}