mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 04:50:26 +08:00
Update workflow
This commit is contained in:
parent
e3baedfff2
commit
8325b7d4f9
40
.github/workflows/main2.yml
vendored
40
.github/workflows/main2.yml
vendored
@ -1,40 +0,0 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Shadow
|
||||
|
||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
||||
# events but only for the master branch
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build with Gradle and shadowJar
|
||||
run: ./gradlew :mirai-core:shadowJar :mirai-core-qqandroid:shadowJar
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
# Artifact name
|
||||
name: mirai-core-all
|
||||
# Directory containing files to upload
|
||||
path: "mirai-core/build/libs/mirai-core-*-all.jar"
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
# Artifact name
|
||||
name: mirai-core-qqandroid-all
|
||||
# Directory containing files to upload
|
||||
path: "mirai-core-qqandroid/build/libs/mirai-core-qqandroid-*-all.jar"
|
48
.github/workflows/shadow.yml
vendored
Normal file
48
.github/workflows/shadow.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Shadow Publish
|
||||
|
||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
||||
# events but only for the master branch
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Gradle clean
|
||||
run: ./gradlew clean
|
||||
- name: Gradle build
|
||||
run: ./gradlew build
|
||||
- name: Gradle :mirai-core:githubUpload
|
||||
run: ./gradlew :mirai-core:githubUpload -Dgithub_token=${{ secrets.MAMOE_TOKEN }}
|
||||
- name: Gradle :mirai-core-qqandroid:githubUpload
|
||||
run: ./gradlew :mirai-core-qqandroid:githubUpload -Dgithub_token=${{ secrets.MAMOE_TOKEN }}
|
||||
|
||||
|
||||
# - name: Upload artifact
|
||||
# uses: actions/upload-artifact@v1.0.0
|
||||
# with:
|
||||
# # Artifact name
|
||||
# name: mirai-core
|
||||
# # Directory containing files to upload
|
||||
# path: "mirai-core/build/libs/mirai-core-*-all.jar"
|
||||
# - name: Upload artifact
|
||||
# uses: actions/upload-artifact@v1.0.0
|
||||
# with:
|
||||
# # Artifact name
|
||||
# name: mirai-core-qqandroid-all
|
||||
# # Directory containing files to upload
|
||||
# path: "mirai-core-qqandroid/build/libs/mirai-core-qqandroid-*-all.jar"
|
@ -1,4 +1,4 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
|
||||
|
||||
import java.time.Duration
|
||||
import java.util.*
|
||||
@ -60,14 +60,15 @@ subprojects {
|
||||
val shadowJvmJar by tasks.creating(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {
|
||||
group = "mirai"
|
||||
|
||||
val compilation = kotlin.targets.getByName("jvm").compilations["main"]
|
||||
val compilation =
|
||||
kotlin.targets.first { it.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.jvm }.compilations["main"]
|
||||
|
||||
dependsOn(compilation.compileKotlinTask)
|
||||
|
||||
configurations = mutableListOf(compilation.compileDependencyFiles as Configuration)
|
||||
}
|
||||
|
||||
val uploadGitHub by tasks.creating {
|
||||
val githubUpload by tasks.creating {
|
||||
group = "mirai"
|
||||
dependsOn(shadowJvmJar)
|
||||
|
||||
@ -88,7 +89,7 @@ subprojects {
|
||||
val filename = file.name
|
||||
println("Uploading file $filename")
|
||||
runCatching {
|
||||
upload.GitToken.upload(
|
||||
upload.GitHub.upload(
|
||||
file,
|
||||
"https://api.github.com/repositories/249670490/contents/shadow/${project.name}/$filename"
|
||||
)
|
||||
|
@ -6,15 +6,6 @@ repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
all {
|
||||
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
|
||||
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
|
||||
|
@ -5,19 +5,35 @@ package upload
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import io.ktor.client.features.HttpTimeout
|
||||
import io.ktor.client.features.timeout
|
||||
import io.ktor.client.request.put
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
object GitToken {
|
||||
object GitHub {
|
||||
|
||||
private fun getGitToken(): String {
|
||||
with(File(System.getProperty("user.dir")).parent + "/token.txt") {
|
||||
println("reading token file in $this")
|
||||
return File(this).readText()
|
||||
private fun getGithubToken(): String {
|
||||
File(File(System.getProperty("user.dir")).parent, "/token.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")), "/token.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
val property = System.getProperty("github_token", "~")
|
||||
if (property == null || property == "~") {
|
||||
error(
|
||||
"Cannot find github token, " +
|
||||
"please specify by creating a file token.txt in project dir, " +
|
||||
"or by providing JVM parameter 'github_token'"
|
||||
)
|
||||
}
|
||||
return property
|
||||
}
|
||||
|
||||
fun upload(file: File, url: String) = runBlocking {
|
||||
@ -30,12 +46,7 @@ object GitToken {
|
||||
requestTimeoutMillis = 600_000
|
||||
socketTimeoutMillis = 600_000
|
||||
}
|
||||
}.put<String>("""$url?access_token=${getGitToken()}""") {
|
||||
timeout {
|
||||
connectTimeoutMillis = 600_000
|
||||
requestTimeoutMillis = 600_000
|
||||
socketTimeoutMillis = 600_000
|
||||
}
|
||||
}.put<String>("""$url?access_token=${getGithubToken()}""") {
|
||||
val content = String(Base64.getEncoder().encode(file.readBytes()))
|
||||
body = """
|
||||
{
|
Loading…
Reference in New Issue
Block a user