-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper.scala
executable file
·54 lines (44 loc) · 1.77 KB
/
helper.scala
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
#!/usr/bin/env -S scala shebang
//> using toolkit 0.5.0
//> using dep io.github.pme123::camundala-helper:1.30.29
import camundala.helper.dev.publish.ChangeLogUpdater
@main
def release(version: String): Unit =
println(s"Publishing camundala: $version")
ChangeLogUpdater.verifyChangelog(version)
val releaseVersion = """^(\d+)\.(\d+)\.(\d+)(-.*)?$"""
if !version.matches(releaseVersion) then
throw new IllegalArgumentException(
"Your Version has not the expected format (2.1.2(-SNAPSHOT))"
)
replaceVersion(version)
val isSnapshot = version.contains("-")
runInConsole("sbt", "-J-Xmx3G", "docs/mdoc", "docs/laikaSite")
if !isSnapshot then
runInConsole("sbt", "-J-Xmx3G", "publishSigned")
runInConsole("git", "fetch", "--all")
runInConsole("git", "commit", "-a", "-m", s"Released Version $version")
runInConsole("git", "tag", "-a", s"v$version", "-m", s"Version $version")
runInConsole("git", "checkout", "master")
runInConsole("git", "merge", "develop")
runInConsole("git", "push", "--tags")
runInConsole("git", "checkout", "develop")
val pattern = """^(\d+)\.(\d+)\.(\d+)$""".r
val newVersion = version match
case pattern(major, minor, _) =>
s"$major.${minor.toInt + 1}.0-SNAPSHOT"
replaceVersion(newVersion)
runInConsole("git", "commit", "-a", "-m", s"Init new Version $newVersion")
runInConsole("git", "push", "--all")
println(s"Published Version: $version")
else
runInConsole("sbt", "-J-Xmx3G", "publishLocal")
end if
end release
private def replaceVersion(newVersion: String) =
val versionsPath = os.pwd / "version"
os.write.over(versionsPath, newVersion)
private def runInConsole(proc: String*) =
println(proc.mkString(" "))
val result = os.proc(proc).call()
println(result.out.text())