Feature: Modrinth version names (#4989)

* Feature: Version names on modrinth published builds

* Also change the fabric/neoforge jar file names
This commit is contained in:
chris 2024-08-25 21:31:03 +02:00 committed by GitHub
parent 2274377814
commit efe8077093
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 6 deletions

View file

@ -118,3 +118,12 @@ open class DownloadFilesTask : DefaultTask() {
private fun calcExclusion(section: String, bit: Int, excludedOn: Int): String =
if (excludedOn and bit > 0) section else ""
fun projectVersion(project: Project): String =
project.version.toString().replace("SNAPSHOT", "b" + buildNumber())
fun versionName(project: Project): String =
"Geyser-" + project.name.replaceFirstChar { it.uppercase() } + "-" + projectVersion(project)
fun buildNumber(): Int =
(System.getenv("BUILD_NUMBER"))?.let { Integer.parseInt(it) } ?: -1

View file

@ -87,7 +87,7 @@ tasks {
register("remapModrinthJar", RemapJarTask::class) {
dependsOn(shadowJar)
inputFile.set(shadowJar.get().archiveFile)
archiveVersion.set(project.version.toString() + "+build." + System.getenv("BUILD_NUMBER"))
archiveVersion.set(versionName(project))
archiveClassifier.set("")
}
}

View file

@ -8,7 +8,8 @@ tasks.modrinth.get().dependsOn(tasks.modrinthSyncBody)
modrinth {
token.set(System.getenv("MODRINTH_TOKEN") ?: "") // Even though this is the default value, apparently this prevents GitHub Actions caching the token?
projectId.set("geyser")
versionNumber.set(project.version as String + "-" + System.getenv("BUILD_NUMBER"))
versionName.set(versionName(project))
versionNumber.set(projectVersion(project))
versionType.set("beta")
changelog.set(System.getenv("CHANGELOG") ?: "")
gameVersions.addAll("1.21", libs.minecraft.get().version as String)

View file

@ -103,9 +103,6 @@ sourceSets {
}
}
fun buildNumber(): Int =
(System.getenv("BUILD_NUMBER"))?.let { Integer.parseInt(it) } ?: -1
fun isDevBuild(branch: String, repository: String): Boolean {
return branch != "master" || repository.equals("https://github.com/GeyserMC/Geyser", ignoreCase = true).not()
}
@ -139,7 +136,7 @@ inner class GitInfo {
buildNumber = buildNumber()
isDev = isDevBuild(branch, repository)
val projectVersion = if (isDev) project.version else project.version.toString().replace("SNAPSHOT", "b${buildNumber}")
val projectVersion = if (isDev) project.version else projectVersion(project)
version = "$projectVersion ($gitVersion)"
}
}