From fb0c90c62abf42171393d3b348bb8af7ec3be244 Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Sun, 9 Jun 2024 15:58:16 +0200 Subject: [PATCH] Add unifiedPublishing Allows for easier uploading to Modrinth and CurseForge --- build.gradle | 75 ++++++++++++++++++++++++++++++++--------------- gradle.properties | 3 ++ settings.gradle | 1 + 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index e07f299..e49ad6b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'fabric-loom' version '1.6-SNAPSHOT' - id 'maven-publish' + id "me.shedaniel.unified-publishing" version "0.1.+" } sourceCompatibility = JavaVersion.VERSION_17 @@ -56,26 +56,55 @@ remapJar { archiveBaseName = "${project.archivesBaseName}" } -// configure the maven publication -publishing { - publications { - mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar - } - - artifact(sourcesJar) { - builtBy remapSourcesJar - } - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - } +ext { + releaseChangelog = { + def changes = new StringBuilder() + changes << "## Sword Blocking v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/SwordBlocking/commits/)" + def proc = "git log --max-count=1 --pretty=format:%s".execute() + proc.in.eachLine { line -> + def processedLine = line.toString() + if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) { + changes << "\n- ${processedLine.capitalize()}" + } + } + proc.waitFor() + return changes.toString() + } } + + +unifiedPublishing { + project { + displayName = "Sword Blocking v$project.version - Fabric $project.minecraft_version" + releaseType = "$project.release_type" + changelog = releaseChangelog() + gameVersions = [] + gameLoaders = ["fabric","quilt"] + mainPublication remapJar + relations { + depends { + curseforge = "midnightlib" + modrinth = "midnightlib" + } + } + + var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") + if (CURSEFORGE_TOKEN != null) { + curseforge { + token = CURSEFORGE_TOKEN + id = rootProject.curseforge_id + gameVersions.addAll "Java 21", project.minecraft_version + } + } + + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if (MODRINTH_TOKEN != null) { + modrinth { + token = MODRINTH_TOKEN + id = rootProject.modrinth_id + version = "$project.version-$project.name" + gameVersions.addAll project.minecraft_version + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 35f18d8..1875bf4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,9 @@ org.gradle.parallel=true mod_version = 1.3.2 maven_group = eu.midnightdust archives_base_name = swordblocking + release_type=release + curseforge_id=427738 + modrinth_id=4q52b4lD # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api diff --git a/settings.gradle b/settings.gradle index 5b60df3..0de6ae7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,6 +5,7 @@ pluginManagement { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + maven { url "https://maven.architectury.dev/" } gradlePluginPortal() } }