-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle.kts
102 lines (79 loc) · 3.24 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import com.blamejared.modtemplate.Utils
import com.diluv.schoomp.Webhook
import com.diluv.schoomp.message.Message
import com.diluv.schoomp.message.embed.Embed
import java.io.IOException
import java.util.*
plugins {
// Need to know about base for posting to CF
base
id("com.blamejared.modtemplate")
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.diluv.schoomp:Schoomp:1.2.6")
}
}
val modName = extra["mod.name"] as String
val mcVersion = extra["minecraft.version"] as String
val modRepo = extra["mod.repo"] as String
val modAvatar = extra["mod.avatar"] as String
tasks.create("postDiscord") {
doLast {
try {
// Create a new webhook instance for Discord
val webhook = Webhook(
System.getenv("discordCFWebhook"),
"${modName} CurseForge Gradle Upload"
)
// Craft a message to send to Discord using the webhook.
val message = Message()
message.username = modName
message.avatarUrl = modAvatar
message.content = "${modName} $version for Minecraft ${mcVersion} has been published!"
val embed = Embed()
val downloadSources = StringJoiner("\n")
if (project(":fabric").ext.has("curse_file_url")) {
downloadSources.add("<:fabric:932163720568782878> [Fabric](${project(":fabric").ext.get("curse_file_url")})")
}
if (project(":forge").ext.has("curse_file_url")) {
downloadSources.add("<:forge:932163698003443804> [Forge](${project(":forge").ext.get("curse_file_url")})")
}
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":core").group}:${project(":core").base.archivesName.get()}:${
project(":core").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":fabric").group}:${project(":fabric").base.archivesName.get()}:${
project(":fabric").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":forge").group}:${project(":forge").base.archivesName.get()}:${
project(":forge").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"${project(":vanilla").group}:${project(":vanilla").base.archivesName.get()}:${
project(":vanilla").version
}\"`"
)
// Add Curseforge DL link if available.
val downloadString = downloadSources.toString()
if (downloadString.isNotEmpty()) {
embed.addField("Download", downloadString, false)
}
// Just use the Forge changelog for now, the files are the same anyway.
embed.addField("Changelog", Utils.getCIChangelog(project, modRepo).take(1000), false)
embed.color = 0xF16436
message.addEmbed(embed)
webhook.sendMessage(message)
} catch (e: IOException) {
project.logger.error("Failed to push CF Discord webhook.")
}
}
}