From 725e505514d5e09bf320e1909353fce186503d2f Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 11 Aug 2023 15:54:59 +1000 Subject: [PATCH] Also handle release versions on publish --- universal/build.gradle.kts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/universal/build.gradle.kts b/universal/build.gradle.kts index 345c9847..9e2a9369 100644 --- a/universal/build.gradle.kts +++ b/universal/build.gradle.kts @@ -44,9 +44,15 @@ tasks { publishShadowJar() val branch = rootProject.branchName() +val baseVersion = project.version as String +val isRelease = !baseVersion.contains('-') +val suffixedVersion = if (isRelease) baseVersion else baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER") +val changelogContent = if (isRelease) { + "See [GitHub](https://github.com/ViaVersion/ViaBackwards) for release notes." +} else { + rootProject.lastCommitMessage() +} val isMainBranch = branch == "master" -val ver = (project.version as String) + "+" + System.getenv("GITHUB_RUN_NUMBER") -val changelogContent = rootProject.lastCommitMessage() modrinth { // val snapshotVersion = rootProject.parseMinecraftSnapshotVersion(project.version as String) val mcVersions: List = (property("mcVersions") as String) @@ -56,9 +62,9 @@ modrinth { token.set(System.getenv("MODRINTH_TOKEN")) projectId.set("viabackwards") - versionType.set(if (isMainBranch) "beta" else "alpha") - versionNumber.set(ver) - versionName.set(ver) + versionType.set(if (isRelease) "release" else if (isMainBranch) "beta" else "alpha") + versionNumber.set(suffixedVersion) + versionName.set(suffixedVersion) changelog.set(changelogContent) uploadFile.set(tasks.shadowJar.flatMap { it.archiveFile }) gameVersions.set(mcVersions) @@ -80,9 +86,9 @@ modrinth { if (isMainBranch) { // Don't spam releases until Hangar has per channel notifications hangarPublish { publications.register("plugin") { - version.set(ver) + version.set(suffixedVersion) namespace("ViaVersion", "ViaBackwards") - channel.set(if (isMainBranch) "Snapshot" else "Alpha") + channel.set(if (isRelease) "Release" else if (isMainBranch) "Snapshot" else "Alpha") changelog.set(changelogContent) apiKey.set(System.getenv("HANGAR_TOKEN")) platforms {