Skip to content

Commit 2351797

Browse files
committed
Improve platform version format
1 parent 2963018 commit 2351797

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,21 @@ tasks {
230230
}
231231
}
232232

233+
val versionPattern = "(?<ver>[\\d.]+)-?(?<channel>beta)?\\.?(?<mod>\\d+)?\\+?(?<game>[\\d.]+)?(?:\\+(?<dev>dev)?-?(?<hash>.+)?)?".toRegex()
234+
233235
publishMods {
234236
file.set(fullJar.flatMap { it.archiveFile })
235237
changelog.set(providers.environmentVariable("CHANGELOG").orElse("# $version"))
236238
type.set(PUBLISH_RELEASE_TYPE.orElse("alpha").map(ReleaseType::of))
237239
modLoaders.add("neoforge")
238240
dryRun.set(!providers.environmentVariable("CI").isPresent)
241+
displayName.set(version.map { s ->
242+
val matched = versionPattern.matchEntire(s) ?: throw IllegalArgumentException("Unexpected version format")
243+
val mainVer = matched.groups["ver"]?.value ?: throw IllegalArgumentException("Missing main version")
244+
val channelVer = matched.groups["channel"]?.value?.let { it + (matched.groups["mod"]?.value?.let { m -> " $m" } ?: "") } ?: ""
245+
val devHash = matched.groups["hash"]?.value?.let { "(dev $it)" } ?: ""
246+
"Connector $mainVer" + (if (channelVer.isNotEmpty()) " $channelVer" else "") + (if (devHash.isNotEmpty()) " $devHash" else "")
247+
})
239248

240249
github {
241250
accessToken.set(providers.environmentVariable("GITHUB_TOKEN"))

0 commit comments

Comments
 (0)