Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
8325b7d4
Commit
8325b7d4
authored
Mar 25, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update workflow
parent
e3baedff
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
25 deletions
+76
-25
.github/workflows/shadow.yml
.github/workflows/shadow.yml
+48
-0
build.gradle.kts
build.gradle.kts
+5
-4
buildSrc/build.gradle.kts
buildSrc/build.gradle.kts
+0
-9
buildSrc/src/main/kotlin/upload/GitHub.kt
buildSrc/src/main/kotlin/upload/GitHub.kt
+23
-12
No files found.
.github/workflows/
main2
.yml
→
.github/workflows/
shadow
.yml
View file @
8325b7d4
# This is a basic workflow to help you get started with Actions
name
:
Shadow
name
:
Shadow
Publish
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
...
...
@@ -22,19 +22,27 @@ jobs:
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"
-
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"
build.gradle.kts
View file @
8325b7d4
@
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
.
Git
Token
.
upload
(
upload
.
Git
Hub
.
upload
(
file
,
"https://api.github.com/repositories/249670490/contents/shadow/${project.name}/$filename"
)
...
...
buildSrc/build.gradle.kts
View file @
8325b7d4
...
...
@@ -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"
...
...
buildSrc/src/main/kotlin/upload/Git
Token
.kt
→
buildSrc/src/main/kotlin/upload/Git
Hub
.kt
View file @
8325b7d4
...
...
@@ -5,21 +5,37 @@ 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
Git
Token
{
object
Git
Hub
{
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
getGit
hub
Token
():
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
{
HttpClient
(
CIO
)
{
engine
{
...
...
@@ -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
=
"""
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment