-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
25 lines (21 loc) · 778 Bytes
/
Copy pathbuild.gradle.kts
File metadata and controls
25 lines (21 loc) · 778 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
plugins {
alias(libs.plugins.spotless) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.publish) apply false
}
group = "me.devnatan"
version = property("version")
.toString()
.takeUnless { it == "unspecified" }
?.filterNot { it == 'v' } ?: nextGitTag()
@Suppress("UnstableApiUsage")
fun Project.nextGitTag(): String {
val latestTag = providers.exec {
workingDir(project.projectDir)
commandLine("git", "describe", "--tags", "--abbrev=0")
}.standardOutput.asText.get().trim()
val versionParts = latestTag.removePrefix("v").split(".")
val major = versionParts.getOrNull(0)?.toIntOrNull() ?: 0
val minor = versionParts.getOrNull(1)?.toIntOrNull() ?: 0
return "$major.${minor + 1}.0-SNAPSHOT"
}