mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Update build.gradle with github task
This commit is contained in:
parent
d91cbaa24b
commit
660a41a18a
38
build.gradle
38
build.gradle
@ -1,8 +1,16 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'org.kohsuke:github-api:1.135'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
def ENV = System.getenv()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
@ -83,13 +91,35 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
// Loom 0.11's devlibs folder messes with my other scripts,
|
||||
// so I'm moving these files back to the old location.
|
||||
tasks.named("remapJar") {
|
||||
task moveDevLibs(dependsOn: [remapJar, remapSourcesJar]) {
|
||||
doLast {
|
||||
ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-dev.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
|
||||
ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-sources.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-sources-dev.jar")
|
||||
}
|
||||
}
|
||||
|
||||
import org.kohsuke.github.GHReleaseBuilder
|
||||
import org.kohsuke.github.GitHub
|
||||
|
||||
task github(dependsOn: moveDevLibs) {
|
||||
onlyIf {
|
||||
ENV.GITHUB_TOKEN
|
||||
}
|
||||
|
||||
doLast {
|
||||
def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String)
|
||||
def repository = github.getRepository("Wurst-Imperium/Wurst-MCX2")
|
||||
def ghVersion = "v" + version.substring(0, version.indexOf("-"))
|
||||
|
||||
def ghRelease = repository.getReleaseByTagName(ghVersion as String);
|
||||
if(ghRelease == null) {
|
||||
def releaseBuilder = new GHReleaseBuilder(repository, ghVersion as String)
|
||||
ghRelease = releaseBuilder.create()
|
||||
}
|
||||
|
||||
ghRelease.uploadAsset(remapJar.archiveFile.get().getAsFile(), "application/java-archive");
|
||||
ghRelease.uploadAsset(remapSourcesJar.archiveFile.get().getAsFile(), "application/java-archive")
|
||||
ghRelease.uploadAsset(new File("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar"), "application/java-archive")
|
||||
ghRelease.uploadAsset(new File("${project.buildDir}/libs/${archivesBaseName}-${version}-sources-dev.jar"), "application/java-archive")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user