Gradle tasks for uploading artifacts

This commit is contained in:
Him188 2020-03-25 12:18:58 +08:00
parent 588d2d16ca
commit e3baedfff2
2 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,6 @@
@file:Suppress("UnstableApiUsage")
import java.time.Duration
import java.util.*
import kotlin.math.pow
@ -69,6 +72,7 @@ subprojects {
dependsOn(shadowJvmJar)
doFirst {
timeout.set(Duration.ofMinutes(10))
File(projectDir, "build/libs").walk()
.filter { it.isFile }
.onEach { println("all files=$it") }
@ -82,11 +86,15 @@ subprojects {
}
}?.let { (_, file) ->
val filename = file.name
println("filename=$filename")
upload.GitToken.upload(
file,
"https://api.github.com/repos/mamoe/mirai-repo/contents/shdaow/${project.name}/$filename"
)
println("Uploading file $filename")
runCatching {
upload.GitToken.upload(
file,
"https://api.github.com/repositories/249670490/contents/shadow/${project.name}/$filename"
)
}.exceptionOrNull()?.let {
System.err.println("Upload failed")
}
}
}

View File

@ -22,7 +22,14 @@ object GitToken {
fun upload(file: File, url: String) = runBlocking {
HttpClient(CIO) {
install(HttpTimeout)
engine {
requestTimeout = 600_000
}
install(HttpTimeout) {
connectTimeoutMillis = 600_000
requestTimeoutMillis = 600_000
socketTimeoutMillis = 600_000
}
}.put<String>("""$url?access_token=${getGitToken()}""") {
timeout {
connectTimeoutMillis = 600_000