|
| 1 | +import org.kohsuke.github.GHReleaseBuilder |
| 2 | +import org.kohsuke.github.GitHub |
1 | 3 | import java.nio.file.Files |
2 | 4 |
|
| 5 | +buildscript { |
| 6 | + |
| 7 | + dependencies { |
| 8 | + classpath("org.kohsuke:github-api:1.135") |
| 9 | + } |
| 10 | + |
| 11 | + repositories { |
| 12 | + mavenCentral() |
| 13 | + } |
| 14 | +} |
| 15 | + |
3 | 16 | plugins { |
4 | 17 | alias(libs.plugins.loom) |
5 | 18 | alias(libs.plugins.minotaur) |
@@ -163,6 +176,7 @@ publishing { |
163 | 176 | } |
164 | 177 |
|
165 | 178 | val modrinthToken: Provider<String> = providers.gradleProperty("modrinthToken") |
| 179 | +val githubToken: Provider<String> = providers.gradleProperty("githubToken") |
166 | 180 |
|
167 | 181 | if (modrinthToken.isPresent) { |
168 | 182 | modrinth { |
@@ -202,3 +216,27 @@ fun resolveLwjglNatives(): String { // Sourced from https://www.lwjgl.org/ |
202 | 216 | } |
203 | 217 | } |
204 | 218 | } |
| 219 | + |
| 220 | +if(githubToken.isPresent){ |
| 221 | + tasks.register("github") { |
| 222 | + doLast { |
| 223 | + val github = GitHub.connectUsingOAuth(githubToken.get()) |
| 224 | + val repository = github.getRepository("Turnip-Labs/bta-halplibe") |
| 225 | + |
| 226 | + val releaseBuilder = GHReleaseBuilder(repository, version.toString()) |
| 227 | + releaseBuilder.name("HalpLibe $version") |
| 228 | + releaseBuilder.body(Files.readString(rootProject.projectDir.toPath().resolve("CHANGELOG.md"))) |
| 229 | + releaseBuilder.commitish("8.0") |
| 230 | + val release = releaseBuilder.create() |
| 231 | + release.uploadAsset( |
| 232 | + project.file(tasks.named("jar").get().outputs.files.singleFile), |
| 233 | + "application/java-archive" |
| 234 | + ) |
| 235 | + release.uploadAsset( |
| 236 | + project.file(tasks.named("sourcesJar").get().outputs.files.singleFile), |
| 237 | + "application/java-archive" |
| 238 | + ) |
| 239 | + } |
| 240 | + } |
| 241 | + |
| 242 | +} |
0 commit comments