diff --git a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt index d3f380128..d890d3208 100644 --- a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt +++ b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt @@ -15,8 +15,8 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.attributes +import org.gradle.kotlin.dsl.getByName import java.io.File -import kotlin.math.pow class MiraiConsoleBuildPlugin : Plugin { override fun apply(target: Project) = target.run { @@ -97,7 +97,11 @@ class MiraiConsoleBuildPlugin : Plugin { } } -fun Project.findLatestFile(): Map.Entry { +fun Project.findLatestFile(): Pair { + return tasks.getByName("shadowJar", ShadowJar::class).run { + val file = archiveFile.get().asFile + this@findLatestFile.version.toString() to file + }/* return File(projectDir, "build/libs").walk() .filter { it.isFile } .onEach { println("all files=$it") } @@ -112,7 +116,7 @@ fun Project.findLatestFile(): Map.Entry { }.reversed().foldIndexed(0) { index: Int, acc: Int, s: String -> acc + 100.0.pow(index).toInt() * (s.toIntOrNull() ?: 0) } - } ?: error("cannot find any file to upload") + } ?: error("cannot find any file to upload")*/ } val gitVersion: String by lazy { diff --git a/buildSrc/src/main/kotlin/upload/GitHub.kt b/buildSrc/src/main/kotlin/upload/GitHub.kt index 1a91f8d24..6710ca500 100644 --- a/buildSrc/src/main/kotlin/upload/GitHub.kt +++ b/buildSrc/src/main/kotlin/upload/GitHub.kt @@ -63,6 +63,18 @@ object GitHub { } } + project.file("token.txt").let { local -> + if (local.exists()) { + return local.readText().trim() + } + } + + project.rootProject.file("token.txt").let { local -> + if (local.exists()) { + return local.readText().trim() + } + } + error( "Cannot find github token, " + "please specify by creating a file token.txt in project dir, " +