-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_release.sbt
executable file
·61 lines (53 loc) · 1.63 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
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.*
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,
setToMyReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
releaseStepCommand("ci-docker"),
setToMyNextVersion,
releaseStepCommand("scalafmt"),
gitAddAllTask,
commitNextVersion,
pushChanges
)
}