-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
60 lines (56 loc) · 1.98 KB
/
build.gradle.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
plugins {
alias(libs.plugins.jvm) apply false
}
allprojects {
version = "0.4.0"
repositories {
mavenCentral()
repositories {
maven {
url = uri("https://maven.pkg.github.com/DonRobo/shelly-api")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GH_USER")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GH_TOKEN")
}
}
}
}
}
task("setVersion") {
doLast {
val versionToSet = project.findProperty("newVersion") as String
val thisFile = File("build.gradle.kts")
var versionRegex = Regex("(\\s*)version\\s*=\\s*\"\\d+\\.\\d+\\.\\d+\"\\s*")
var count = 0
val content = thisFile.readLines()
.map { line ->
val match = versionRegex.matchEntire(line)
if (match != null) {
count++
"${match.groupValues[1]}version = \"$versionToSet\""
} else {
line
}
}
require(count == 1) {
"Expected to find exactly one version line in '${thisFile.name}', found $count"
}
thisFile.writeText(content.joinToString("\n"))
versionRegex = Regex("(\\s*)version\\s*:\\s*\"\\d+\\.\\d+\\.\\d+\"\\s*")
val configYamlFile = File("home-assistant-addon/config.yaml")
count = 0
val configYamlContent = configYamlFile.readLines().map {
val match = versionRegex.matchEntire(it)
if (match != null) {
count++
"${match.groupValues[1]}version: \"$versionToSet\""
} else {
it
}
}
require(count == 1) {
"Expected to find exactly one version line in '${configYamlFile.name}', found $count"
}
configYamlFile.writeText(configYamlContent.joinToString("\n"))
}
}