From 8d04785e3a8afe275edea6b2770e19879d9d71da Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sat, 2 Nov 2024 19:08:43 +0100 Subject: [PATCH] Use snapshot repo for snapshot versions --- buildSrc/src/main/kotlin/bluemap.base.gradle.kts | 5 ++++- buildSrc/src/main/kotlin/versioning.kt | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/bluemap.base.gradle.kts b/buildSrc/src/main/kotlin/bluemap.base.gradle.kts index 8c1c0b4f..078ba7bd 100644 --- a/buildSrc/src/main/kotlin/bluemap.base.gradle.kts +++ b/buildSrc/src/main/kotlin/bluemap.base.gradle.kts @@ -73,7 +73,10 @@ publishing { repositories { maven { name = "bluecolored" - url = uri( "https://repo.bluecolored.de/releases" ) + url = uri("https://repo.bluecolored.de/releases") + + if (!gitIsRelease()) + url = uri("https://repo.bluecolored.de/snapshots") credentials { username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME") diff --git a/buildSrc/src/main/kotlin/versioning.kt b/buildSrc/src/main/kotlin/versioning.kt index 687b2c74..b79ac65d 100644 --- a/buildSrc/src/main/kotlin/versioning.kt +++ b/buildSrc/src/main/kotlin/versioning.kt @@ -24,6 +24,12 @@ fun Project.gitVersion(): String { return gitVersion } +fun Project.gitIsRelease(): Boolean { + val lastTag = if (runCommand("git tag", "").isEmpty()) "" else runCommand("git describe --tags --abbrev=0", "") + val commits = runCommand("git rev-list --count $lastTag..HEAD", "0") + return commits == "0" && gitClean() +} + fun Project.releaseNotes(): String { val file = rootProject.projectDir.resolve("release.md") if (!file.exists()) return ""