-
Notifications
You must be signed in to change notification settings - Fork 3
/
publish-release.sc
169 lines (155 loc) · 3.49 KB
/
publish-release.sc
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env amm
import mainargs._
/** <pre>
* Creates a new Release for the DmnTester (Library and Docker) and the camunda-dmn-tester-ci (Docker):
*
* amm ./publish-release.sc <VERSION>
*
* # Example SNAPSHOT (only publish to SNAPSHOT Repo, e.g. bpfpkg-maven-dev)
* amm ./publish-release.sc 0.2.5-SNAPSHOT
*
* # Example (publish to Release Repo (e.g. bpfpkg-maven-release) and GIT Tagging and increasing Version to next minor Version)
* amm ./publish-release.sc 0.2.5
*/
private implicit val workDir: os.Path = {
val wd = os.pwd
println(s"Working Directory: $wd")
wd
}
private def replaceVersion(version: String) = {
val pattern = """^(\d+)\.(\d+)\.(\d+)$""".r
val newVersion = version match {
case pattern(major, minor, _) =>
s"$major.${minor.toInt + 1}.0-SNAPSHOT"
}
os.write.over(os.pwd / "version", newVersion)
newVersion
}
private def publishCIDocker(version: String) = {
os.write.over(os.pwd / "docker" / "data" / "testerVersion", version)
runAndPrint( "docker",
"build",
os.pwd / "docker",
"-t",
s"pame/camunda-dmn-tester-ci:$version"
)
runAndPrint( "docker",
"push",
s"pame/camunda-dmn-tester-ci:$version"
)
}
private def updateGit(version: String) = {
runAndPrint( "git",
"fetch",
"--all"
)
runAndPrint( "git",
"commit",
"-a",
"-m",
s"Released Version $version"
)
runAndPrint( "git",
"tag",
"-a",
version,
"-m",
s"Version $version"
)
runAndPrint( "git",
"push",
"--set-upstream",
"origin",
"develop"
)
runAndPrint( "git",
"checkout",
"master"
)
runAndPrint( "git",
"merge",
"develop"
)
runAndPrint( "git",
"push",
"--tags"
)
runAndPrint( "git",
"checkout",
"develop"
)
val newVersion = replaceVersion(version)
runAndPrint( "git",
"commit",
"-a",
"-m",
s"Init new Version $newVersion"
)
runAndPrint( "git",
"push"
)
}
def publishTesterDocker(version: String) = {
os.write.over(os.pwd / "version", version)
buildClient
runAndPrint(
"sbt",
"-J-Xmx3G",
"release",
"publishSigned",
"server/docker:publish"
)
}
def publishTesterDockerLocal = {
buildClient
runAndPrint(
"sbt",
"-J-Xmx3G",
"release",
"publishLocal",
"server/docker:publishLocal"
)
}
def buildClient = {
runAndPrint(
"sbt",
"-J-Xmx3G",
"releaseClient",
)
runAndPrint(
"npm",
"run",
"build",
)
}
def runAndPrint(commands: os.Shellable*) = {
println(s"Commands: ${commands.mkString(", ")}")
println(os.proc(commands:_*).call())
}
@arg(
doc =
"> Creates a new Release for the package and publishes to bpf-generic-release"
)
@main
def release(version: String): Unit = {
println(s"Publishing BPF Package: $version")
val releaseVersion = """^(\d+)\.(\d+)\.(\d+)(-.*)?$"""
if (!version.matches(releaseVersion))
throw new IllegalArgumentException(
"Your Version has not the expected format (2.1.2(-SNAPSHOT))"
)
val isSnapshot = version.contains("-")
if (!isSnapshot) {
publishTesterDocker(version)
publishCIDocker(version)
updateGit(version)
println("""Due to problems with the `"org.xerial.sbt" % "sbt-sonatype"` Plugin you have to release manually:
|- https://s01.oss.sonatype.org/#stagingRepositories
| - login
| - check Staging Repository
| - hit _close_ Button
| - hit _release_ Button""".stripMargin)
} else {
publishTesterDockerLocal
}
}