Skip to content

Commit

Permalink
chore: release files extra fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Dec 10, 2024
1 parent 906c731 commit 49ea66c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 17 deletions.
53 changes: 53 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ buildscript {


plugins {
id "com.modrinth.minotaur" version "2.+"
id 'dev.s7a.gradle.minecraft.server' version '1.1.0'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
}
Expand Down Expand Up @@ -51,6 +52,7 @@ allprojects {


apply from: 'env-variables.gradle'
apply from: 'changelog-util.gradle'


println("Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'")
Expand Down Expand Up @@ -195,5 +197,56 @@ idea {
}
}

modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinth_slug
versionType = "release"
uploadFile = jar
loaders = ["spigot"]
gameVersions = [
"1.13",
"1.13.1",
"1.13.2",
"1.14",
"1.14.1",
"1.14.2",
"1.14.3",
"1.14.4",
"1.15",
"1.15.1",
"1.15.2",
"1.16",
"1.16.1",
"1.16.2",
"1.16.3",
"1.16.4",
"1.16.5",
"1.17",
"1.17.1",
"1.18",
"1.18.1",
"1.18.2",
"1.19",
"1.19.1",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",
"1.20.3",
"1.20.4",
"1.20.5",
"1.20.6",
"1.21",
"1.21.1",
"1.21.2",
"1.21.3",
"1.21.4"
]
changelog = getReleaseChangelog()
}


apply from: 'curse.gradle'
apply from: 'discord.gradle'
5 changes: 5 additions & 0 deletions changelog-util.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ext.getReleaseChangelog = {
def changelogFile = file('CHANGELOG.md')
def changelog = "## [${changelogFile.text.split('\n## \\[')[1]}\n\n" // ${project.github}/blob/${branch}/CHANGELOG.md
return changelog
}
29 changes: 12 additions & 17 deletions discord.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@ buildscript {
}

apply from: 'env-variables.gradle'

def getReleaseChangelog() {
def changelogFile = file('CHANGELOG.md')
def changelog = "## [${changelogFile.text.split('\n## \\[')[1]}\n\n"// ${project.github}/blob/${branch}/CHANGELOG.md
return changelog;
}
apply from: 'changelog-util.gradle'

task discordupload {
dependsOn(jar)

doLast {

String discordWebhook = System.getenv("DISCORD_WEBHOOK")
String discordWebhook = isRelease ? System.getenv("DISCORD_RELEASE_WEBHOOK") : System.getenv("DISCORD_WEBHOOK")

if(discordWebhook != null) {
println("Logging Into Discord")

CloseableHttpClient httpClient = HttpClients.createDefault()
HttpPost uploadFile = new HttpPost(discordWebhook)
Expand All @@ -43,19 +37,16 @@ task discordupload {
def maxLength = 2000

def content = "New release build\n" +
"```markdown\n" +
"${getReleaseChangelog()}\n" +
"```"
"${getReleaseChangelog()}\n"

if (content.length() > maxLength) {
def trimmedChangelog = getReleaseChangelog().take(maxLength - 15) // Reserve space for ending message
content = "New release build\n" +
"```markdown\n" +
"${trimmedChangelog}\n" +
"``` [Truncated]"
def afterMessage = "[See more on GitHub]"
content = "${content.take(maxLength - afterMessage.length() - 1)}\n" +
"${afterMessage}"

}

builder.addTextBody("content", content)
builder.addTextBody("content", content, ContentType.create("text/plain", "UTF-8"))
}

builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, jar.archiveName)
Expand All @@ -66,6 +57,10 @@ task discordupload {
CloseableHttpResponse response = httpClient.execute(uploadFile)
response.getEntity()

if(response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed to post build to discord")
}

println("Posted build")

} else {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ version=1.0.0

github=https://github.com/sekwah41/Advanced-Portals
curse_project_id=86001
modrinth_slug=advanced-portals
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ include 'spigot'
// Proxies
include 'velocity'
include 'bungee'

0 comments on commit 49ea66c

Please sign in to comment.