Skip to content

Commit f82adfe

Browse files
committed
Super cool publishing
1 parent 72f0577 commit f82adfe

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

build.gradle

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'maven-publish'
44
id 'net.neoforged.moddev' version '2.0.140'
55
id 'idea'
6+
id 'me.modmuss50.mod-publish-plugin' version '1.1.0'
67
}
78

89
tasks.named('wrapper', Wrapper).configure {
@@ -202,3 +203,83 @@ idea {
202203
downloadJavadoc = true
203204
}
204205
}
206+
207+
// ========================
208+
// Changelog & Publishing
209+
// ========================
210+
211+
String getRelevantChangelog(String targetVersion) {
212+
def changelogFile = file("CHANGELOG.md")
213+
if (!changelogFile.exists()) {
214+
return "No changelog found."
215+
}
216+
def lines = changelogFile.readLines()
217+
def result = new StringBuilder()
218+
def capturing = false
219+
def targetMinecraftVersion = targetVersion.split("-")[0]
220+
def targetModVersion = targetVersion.split("-").length > 1 ? targetVersion.split("-")[1] : ""
221+
def newerVersionsExist = false
222+
223+
for (line in lines) {
224+
if (line.startsWith("# ")) {
225+
if (capturing) {
226+
break
227+
}
228+
def versionTag = line.substring(2).trim()
229+
def entryMinecraftVersion = versionTag.split("-")[0]
230+
def entryModVersion = versionTag.split("-").length > 1 ? versionTag.split("-")[1] : ""
231+
if (versionTag == targetVersion) {
232+
capturing = true
233+
continue
234+
}
235+
if (entryMinecraftVersion == targetMinecraftVersion && entryModVersion > targetModVersion) {
236+
newerVersionsExist = true
237+
}
238+
} else if (capturing && line.trim()) {
239+
result.append(line).append("\n")
240+
}
241+
}
242+
243+
if (newerVersionsExist) {
244+
println("WARNING: Publishing an older version! Newer entries exist for Minecraft ${targetMinecraftVersion}.")
245+
}
246+
247+
return result.length() > 0 ? result.toString().trim() : "No changelog entry found for version ${targetVersion}."
248+
}
249+
250+
publishMods {
251+
file = jar.archiveFile
252+
def changelogText = getRelevantChangelog(minecraft_version + "-" + mod_version)
253+
changelog = changelogText
254+
println("Using changelog:\n" + changelogText + "\n")
255+
type = STABLE
256+
modLoaders.add("neoforge")
257+
displayName = mod_name + " " + mod_version + " NeoForge " + minecraft_version
258+
259+
curseforge {
260+
projectId = "1466331"
261+
projectSlug = "azimuth-api"
262+
accessToken = findProperty('curseforgePublishToken')
263+
minecraftVersions.add("1.21.1")
264+
requires("create")
265+
}
266+
modrinth {
267+
projectId = "RpH8tmT1"
268+
accessToken = findProperty('modrinthPublishToken')
269+
minecraftVersions.add("1.21.1")
270+
requires("create")
271+
}
272+
273+
discord {
274+
webhookUrl = findProperty('aztechDiscordPublishWebhook')
275+
username = "azimuth version bot"
276+
avatarUrl = "https://cataas.com/cat?width=500&height=500"
277+
content = """
278+
# New Mod Release: ${getDisplayName().get()}
279+
${changelogText}
280+
""".trim()
281+
style {
282+
look = "CLASSIC"
283+
}
284+
}
285+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod_name=Azimuth
3232
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3333
mod_license=All Rights Reserved
3434
# The mod version. See https://semver.org/
35-
mod_version=1.0.0
35+
mod_version=1.1.0
3636
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3737
# This should match the base package used for the mod sources.
3838
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

0 commit comments

Comments
 (0)