[CI-Skip] Fix & cleanup updateUpstream task
This commit is contained in:
@@ -84,30 +84,22 @@ paperweight {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("updateUpstream") {
|
val upstreamTask = tasks.register("updateUpstream") {
|
||||||
dependsOn("updateUpstreamCommit")
|
finalizedBy("applyPatches")
|
||||||
dependsOn("applyPatches")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("updateUpstreamCommit") {
|
val tempDir = layout.cacheDir("updateUpstream");
|
||||||
// Update the purpurRef in gradle.properties to be the latest commit.
|
|
||||||
val tempDir = layout.cacheDir("purpurRefLatest");
|
|
||||||
val file = "gradle.properties";
|
val file = "gradle.properties";
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
data class GithubCommit(
|
val apiResponse = layout.cache.resolve("apiResponse.json");
|
||||||
val sha: String
|
download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/master", apiResponse);
|
||||||
)
|
val latestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(apiResponse)["sha"].asString;
|
||||||
|
|
||||||
val purpurLatestCommitJson = layout.cache.resolve("purpurLatestCommit.json");
|
|
||||||
download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/master", purpurLatestCommitJson);
|
|
||||||
val purpurLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(purpurLatestCommitJson)["sha"].asString;
|
|
||||||
|
|
||||||
copy {
|
copy {
|
||||||
from(file)
|
from(file)
|
||||||
into(tempDir)
|
into(tempDir)
|
||||||
filter { line: String ->
|
filter { line: String ->
|
||||||
line.replace("paperCommit = .*".toRegex(), "paperCommit = $purpurLatestCommit")
|
line.replace("paperCommit = .*".toRegex(), "paperCommit = $latestCommit")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user