Skip to content

Commit 60c8f90

Browse files
committed
chore: version based on next git tag
1 parent 91d53d9 commit 60c8f90

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

build.gradle.kts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,20 @@ plugins {
55
}
66

77
group = "me.devnatan"
8-
version = "3.3.0"
8+
version = property("version")
9+
.toString()
10+
.takeUnless { it == "unspecified" }
11+
?.filterNot { it == 'v' } ?: nextGitTag()
12+
13+
@Suppress("UnstableApiUsage")
14+
fun Project.nextGitTag(): String {
15+
val latestTag = providers.exec {
16+
commandLine("git", "describe", "--tags", "--abbrev=0")
17+
}.standardOutput.asText.get().trim()
18+
19+
val versionParts = latestTag.removePrefix("v").split(".")
20+
val major = versionParts.getOrNull(0)?.toIntOrNull() ?: 0
21+
val minor = versionParts.getOrNull(1)?.toIntOrNull() ?: 0
22+
23+
return "$major.${minor + 1}.0-SNAPSHOT"
24+
}

0 commit comments

Comments
 (0)