@@ -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
89tasks. 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+ }
0 commit comments