Skip to content

Commit 192dc99

Browse files
committed
gradle: Also append git branch name to continuous builds
Signed-off-by: Aayush Gupta <contact@aayush.io>
1 parent 87e06a4 commit 192dc99

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

app/build.gradle.kts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ plugins {
2121
val gitWorkingBranch = providers.exec {
2222
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
2323
}.standardOutput.asText.map { it.trim() }
24+
val defaultBranches = listOf("master", "dev")
25+
val workingBranch = gitWorkingBranch.getOrElse("")
26+
val normalizedWorkingBranch = workingBranch
27+
.replaceFirst("^[^A-Za-z]+".toRegex(), "")
28+
.replace("[^0-9A-Za-z]+".toRegex(), "")
2429

2530
kotlin {
2631
jvmToolchain(21)
@@ -63,14 +68,7 @@ configure<ApplicationExtension> {
6368
isDebuggable = true
6469

6570
// suffix the app id and the app name with git branch name
66-
val defaultBranches = listOf("master", "dev")
67-
val workingBranch = gitWorkingBranch.getOrElse("")
68-
val normalizedWorkingBranch = workingBranch
69-
.replaceFirst("^[^A-Za-z]+".toRegex(), "")
70-
.replace("[^0-9A-Za-z]+".toRegex(), "")
71-
7271
if (normalizedWorkingBranch.isEmpty() || workingBranch in defaultBranches) {
73-
// default values when branch name could not be determined or is master or dev
7472
applicationIdSuffix = ".debug"
7573
resValue("string", "app_name", "NewPipe Debug")
7674
} else {
@@ -94,9 +92,17 @@ configure<ApplicationExtension> {
9492

9593
register("continuous") {
9694
initWith(getByName("release"))
97-
applicationIdSuffix = ".continuous"
9895
signingConfig = signingConfigs.getByName("debug")
9996
isDefault = true
97+
98+
// suffix the app id and the app name with git branch name
99+
if (normalizedWorkingBranch.isEmpty() || workingBranch in defaultBranches) {
100+
applicationIdSuffix = ".continuous"
101+
resValue("string", "app_name", "NewPipe Continuous")
102+
} else {
103+
applicationIdSuffix = ".continuous.$normalizedWorkingBranch"
104+
resValue("string", "app_name", "NewPipe $workingBranch")
105+
}
100106
}
101107
}
102108

0 commit comments

Comments
 (0)