-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathauto_release.gradle.kts
More file actions
36 lines (29 loc) · 907 Bytes
/
auto_release.gradle.kts
File metadata and controls
36 lines (29 loc) · 907 Bytes
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
import java.io.BufferedReader
tasks.create<DefaultTask>("release") {
val releaseBranch = "master"
val currentBranch = executeCommand("git rev-parse --abbrev-ref HEAD")[0]
val bintrayUploadTasks = subprojects.mapNotNull {
val tasks = it.getTasksByName("bintrayUpload", false)
if (tasks.isNotEmpty()) {
tasks
} else {
null
}
}
if (currentBranch == releaseBranch) {
finalizedBy(bintrayUploadTasks)
}
doFirst {
if (currentBranch == releaseBranch) {
println("Releasing from master branch!")
} else {
println("No master! No release!")
}
}
}
fun executeCommand(command: String): List<String> {
val proc = Runtime.getRuntime().exec(command)
val lines = proc.inputStream.bufferedReader().use(BufferedReader::readLines)
proc.waitFor()
return lines
}