forked from PaulWoitaschek/Voice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.main.kts
executable file
·38 lines (32 loc) · 1.07 KB
/
release.main.kts
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
#!/usr/bin/env kotlin
@file:DependsOn("com.github.ajalt:clikt:2.6.0")
import com.github.ajalt.clikt.core.CliktCommand
import java.io.File
class Release : CliktCommand() {
override fun run() {
execute("./gradlew", "app:bundleProprietaryRelease", "app:assembleProprietaryRelease")
val appVersion = appVersion()
val releaseFolder = File("releases", appVersion)
releaseFolder.mkdirs()
File("app/build/outputs/bundle/proprietaryRelease/app-proprietary-release.aab")
.copyTo(File(releaseFolder, "app.aab"))
File("app/build/outputs/apk/proprietary/release/app-proprietary-release.apk")
.copyTo(File(releaseFolder, "app.apk"))
}
private fun appVersion(): String {
return File("buildSrc/src/main/kotlin/deps/Deps.kt")
.readLines()
.mapNotNull {
"versionName = \"(.*)\"".toRegex().find(it)?.groupValues?.getOrNull(1)
}
.single()
}
private fun execute(vararg command: String) {
ProcessBuilder(*command)
.inheritIO()
.start()
.waitFor()
.also { check(it == 0) }
}
}
Release().main(args)