Add unifiedPublishing

Allows for easier uploading to Modrinth and CurseForge
This commit is contained in:
Martin Prokoph
2024-06-09 15:58:16 +02:00
parent 1c4389e30f
commit fb0c90c62a
3 changed files with 56 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
plugins { plugins {
id 'fabric-loom' version '1.6-SNAPSHOT' id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish' id "me.shedaniel.unified-publishing" version "0.1.+"
} }
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
@@ -56,26 +56,55 @@ remapJar {
archiveBaseName = "${project.archivesBaseName}" archiveBaseName = "${project.archivesBaseName}"
} }
// configure the maven publication ext {
publishing { releaseChangelog = {
publications { def changes = new StringBuilder()
mavenJava(MavenPublication) { changes << "## Sword Blocking v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/SwordBlocking/commits/)"
// add all the jars that should be included when publishing to maven def proc = "git log --max-count=1 --pretty=format:%s".execute()
artifact(remapJar) { proc.in.eachLine { line ->
builtBy remapJar def processedLine = line.toString()
} if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
changes << "\n- ${processedLine.capitalize()}"
artifact(sourcesJar) { }
builtBy remapSourcesJar }
} proc.waitFor()
} return changes.toString()
} }
// 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.
}
} }
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
}
}
}
}

View File

@@ -12,6 +12,9 @@ org.gradle.parallel=true
mod_version = 1.3.2 mod_version = 1.3.2
maven_group = eu.midnightdust maven_group = eu.midnightdust
archives_base_name = swordblocking archives_base_name = swordblocking
release_type=release
curseforge_id=427738
modrinth_id=4q52b4lD
# Dependencies # Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api

View File

@@ -5,6 +5,7 @@ pluginManagement {
name = 'Fabric' name = 'Fabric'
url = 'https://maven.fabricmc.net/' url = 'https://maven.fabricmc.net/'
} }
maven { url "https://maven.architectury.dev/" }
gradlePluginPortal() gradlePluginPortal()
} }
} }