fix(autoversion): try to correct for CI environment
All checks were successful
ci/woodpecker/push/pages Pipeline was successful
ci/woodpecker/push/gradle Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2024-10-10 11:05:27 +02:00
parent 47c14f9c28
commit b18e8d2a5c
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -7,17 +7,20 @@ val isRelease = project.hasProperty("release")
val specialCaseBuilds = setOf("forge", "fabric", "neoforge")
fun List<Tag>.filter(): Pair<Tag, Tag?>? {
if (isEmpty()) return null
if (size == 1) return first() to null
val envName = System.getenv("CI_COMMIT_TAG")
val current = envName?.let { v -> indexOfFirst { it.name == v } } ?: 0
if (current == -1) throw IllegalStateException("Current tag ($envName) not found in tag list")
if (size == current) return get(current) to null
val ver = SemanticVersion.tryParse(first().name)
val ver = SemanticVersion.tryParse(get(current).name)
// special case: some mod projects use the format 1.0.0+forge to classify builds for different loaders
// this ensures changelogs get generated within the same loader branch
if (ver?.build in specialCaseBuilds) {
val preceding = drop(1).firstOrNull { SemanticVersion.tryParse(it.name)?.build == ver?.build }
if (preceding != null) return first() to preceding
val preceding = drop(current + 1).firstOrNull { SemanticVersion.tryParse(it.name)?.build == ver?.build }
if (preceding != null) return get(current) to preceding
}
return first() to get(1)
return get(current) to get(current + 1)
}
versionS = "0.0.0+nogit"