Skip to content

Commit 4b6b5f0

Browse files
committed
Support from 1.21.3 to 1.21.8 & auto publish on hangar
1 parent 30f2440 commit 4b6b5f0

3 files changed

Lines changed: 81 additions & 18 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ jobs:
8181
# prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} #Always release for now
8282
skipIfReleaseExists: true
8383

84-
# Does not work for now.
85-
# - name: Publish to hangar
86-
# env:
87-
# # Make sure you have added a repository secret in the repository's settings
88-
# HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
89-
# run: ./gradlew assemble publishPluginPublicationToHangar --stacktrace
84+
- name: Publish to hangar #& modrinth
85+
env:
86+
# Make sure you have added a repository secret in the repository's settings
87+
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
88+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
89+
run: ./gradlew assemble publishPluginPublicationToHangar #modrinth

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2.1.7
2+
- Support from 1.21.3 to 1.21.8
3+
14
# 2.1.6
25
- Support 1.21.5 & 1.21.6. (From 1.21.3 to 1.21.6)
36

build.gradle.kts

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import io.papermc.hangarpublishplugin.model.Platforms
2-
31
plugins {
42
`java-library`
53
id("io.github.goooler.shadow") version "8.1.7"
@@ -11,10 +9,10 @@ plugins {
119
}
1210

1311
group = "fr.formiko.mc.underilla"
14-
version = "2.1.6"
12+
version = "2.1.7"
1513
description="Generate vanilla cave in custom world."
16-
val mainMinecraftVersion = "1.21.6"
17-
val supportedMinecraftVersions = "1.21.3 - 1.21.6"
14+
val mainMinecraftVersion = "1.21.8"
15+
val supportedMinecraftVersions = "1.21.3 - 1.21.8"
1816
val voidWorldGeneratorVersion = "1.3.2"
1917
val chunkyVersion = "1.4.28"
2018

@@ -30,7 +28,7 @@ repositories {
3028

3129

3230
dependencies {
33-
// compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") // without paperweight
31+
// compileOnly("io.papermc.paper:paper-api:$mainMinecraftVersion-R0.1-SNAPSHOT") // without paperweight
3432
paperweight.paperDevBundle("$mainMinecraftVersion-R0.1-SNAPSHOT")
3533
implementation("fr.formiko.mc.biomeutils:biomeutils:1.1.8")
3634
implementation("com.github.FormikoLudo:Utils:0.0.9")
@@ -126,21 +124,83 @@ tasks.register("echoReleaseName") {
126124
}
127125
}
128126

127+
val extractChangelog = tasks.register("extractChangelog") {
128+
group = "documentation"
129+
description = "Extracts the changelog for the current project version from CHANGELOG.md, including the version header."
130+
131+
val changelog = project.objects.property(String::class)
132+
outputs.upToDateWhen { false }
133+
134+
doLast {
135+
val version = project.version.toString()
136+
val changelogFile = project.file("CHANGELOG.md")
137+
138+
if (!changelogFile.exists()) {
139+
println("CHANGELOG.md not found.")
140+
changelog.set("No changelog found.")
141+
return@doLast
142+
}
143+
144+
val lines = changelogFile.readLines()
145+
val entries = mutableListOf<String>()
146+
var foundVersion = false
147+
148+
for (line in lines) {
149+
when {
150+
// Include the version line itself
151+
line.trim().equals("# $version", ignoreCase = true) -> {
152+
foundVersion = true
153+
entries.add(line)
154+
}
155+
// Stop collecting at the next version header
156+
foundVersion && line.trim().startsWith("# ") -> break
157+
// Collect lines after the version header
158+
foundVersion -> entries.add(line)
159+
}
160+
}
161+
162+
val result = if (entries.isEmpty()) {
163+
"Update to $version."
164+
} else {
165+
entries.joinToString("\n").trim()
166+
}
167+
168+
// println("Changelog for version $version:\n$result")
169+
changelog.set(result)
170+
}
171+
172+
// Make changelog accessible from other tasks
173+
extensions.add("changelog", changelog)
174+
}
175+
176+
tasks.register("echoLatestVersionChangelog") {
177+
group = "documentation"
178+
description = "Displays the latest version change."
179+
180+
dependsOn(tasks.named("extractChangelog"))
181+
182+
doLast {
183+
println((extractChangelog.get().extensions.getByName("changelog") as Property<String>).get())
184+
}
185+
}
186+
129187
val versionString: String = version as String
130188
val isRelease: Boolean = !versionString.contains("SNAPSHOT")
131189

132190
hangarPublish { // ./gradlew publishPluginPublicationToHangar
133191
publications.register("plugin") {
134192
version.set(project.version as String)
135193
channel.set(if (isRelease) "Release" else "Snapshot")
136-
// id.set(project.name as String)
137-
id.set("Underilla")
194+
id.set(project.name)
138195
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
196+
changelog.set(
197+
extractChangelog.map {
198+
(it.extensions.getByName("changelog") as Property<String>).get()
199+
}
200+
)
139201
platforms {
140-
register(Platforms.PAPER) {
141-
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
142-
// jar.set(File("build/libs/${project.name}-${project.version}.jar"))
143-
// externalDownloadUrl.set("https://github.com/HydrolienF/Underilla/releases/download/1.6.14/Underilla-1.6.14.jar")
202+
register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) {
203+
url = "https://github.com/HydrolienF/"+project.name+"/releases/download/"+versionString+"/"+project.name+"-"+versionString+".jar"
144204

145205
// Set platform versions from gradle.properties file
146206
val versions: List<String> = supportedMinecraftVersions.replace(" ", "").split(",")

0 commit comments

Comments
 (0)