Skip to content

Commit 7843317

Browse files
chore(app): build fails when there is an error while generating the changelog (#987)
* Build does not fail anymore when there is an error while generating the changelog * Ignore app changelog update failure with local builds only
1 parent c37bce4 commit 7843317

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

app/build.gradle.kts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,29 @@ dependencies {
146146

147147
tasks.register<DefaultTask>("updateAppChangelog") {
148148
doLast {
149-
updateChangelog(null)
150-
copy {
151-
from("../CHANGELOG.md").into("src/main/res/raw").rename { it.lowercase() }
149+
val rawResourcesPath = "src/main/res/raw"
150+
val changelogFilename = "CHANGELOG.md"
151+
val updateAppChangelog = {
152+
delete("$rawResourcesPath/$changelogFilename")
153+
updateChangelog(null)
154+
copy {
155+
from("../$changelogFilename").into(rawResourcesPath).rename { it.lowercase() }
156+
}
157+
execute("git", "checkout", changelogFilename)
158+
}
159+
// Ignore failure with local builds
160+
val ignoreFailure = Environment.getVariablesOrNull("CI").firstOrNull().toBoolean().not()
161+
if (ignoreFailure) {
162+
try {
163+
updateAppChangelog()
164+
} catch (_: Exception) {
165+
val errorMessage = "There was an error while generating the changelog."
166+
logger.error(errorMessage)
167+
file("$rawResourcesPath/${changelogFilename.lowercase()}").writeText(errorMessage)
168+
}
169+
} else {
170+
updateAppChangelog()
152171
}
153-
execute("git", "checkout", "CHANGELOG.md")
154172
}
155173
}
156174

0 commit comments

Comments
 (0)