Skip to content

Commit ad5fdad

Browse files
committed
ci: use version from tag
1 parent d9a8a8a commit ad5fdad

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.kotlin
33
build
44
*/build
5+
node_modules
6+
version.txt

build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
55

66
plugins {
77
alias(libs.plugins.kotlin.jvm) apply false
8+
alias(libs.plugins.gitVersion)
9+
}
10+
11+
version = computeVersion()
12+
println("Version: $version")
13+
14+
fun computeVersion(): Any {
15+
val versionFile = file("version.txt")
16+
val gitVersion: groovy.lang.Closure<String> by extra
17+
return if (versionFile.exists()) {
18+
versionFile.readText().trim()
19+
} else {
20+
gitVersion()
21+
// Avoid duplicated "-SNAPSHOT" ending
22+
.let { if (it.endsWith("-SNAPSHOT")) it else "$it-SNAPSHOT" }
23+
// Normalize the version so that is always a valid NPM version.
24+
.let { if (it.matches("""\d+\.\d+.\d+-.*""".toRegex())) it else "0.0.1-$it" }
25+
.also { versionFile.writeText(it) }
26+
}
827
}
928

1029
allprojects {

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.0.21" }
1010
shadow = { id = "com.gradleup.shadow", version = "9.0.0-beta6" }
1111
binaryCompatibility = { id ="org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.17.0" }
12+
gitVersion = { id = "com.palantir.git-version", version = "3.1.0" }

renovate.json5

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
$schema: "https://docs.renovatebot.com/renovate-schema.json",
3+
extends: [
4+
"config:best-practices",
5+
// Opt-in to beta support for pre-commit.
6+
// See https://docs.renovatebot.com/modules/manager/pre-commit/
7+
":enablePreCommit",
8+
// Use the same commit type as with Dependabot.
9+
":semanticCommitTypeAll(build)"
10+
],
11+
enabledManagers: [
12+
"pre-commit",
13+
"gradle-wrapper",
14+
"nvm",
15+
"github-actions",
16+
"custom.regex"
17+
],
18+
}

0 commit comments

Comments
 (0)