Skip to content

Commit

Permalink
Add bintray publisher workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Apr 10, 2020
1 parent 3f7bba7 commit 40c22f4
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 113 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/bintray.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is a basic workflow to help you get started with Actions

name: Bintray 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 # if test's failed, don't publish
- name: Gradle :mirai-core:bintrayUpload
run: ./gradlew :mirai-core:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
- name: Gradle :mirai-core-qqandroid:bintrayUpload
run: ./gradlew :mirai-core-qqandroid:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}


# - name: Upload artifact
# uses: actions/[email protected]
# 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/[email protected]
# with:
# # Artifact name
# name: mirai-core-qqandroid-all
# # Directory containing files to upload
# path: "mirai-core-qqandroid/build/libs/mirai-core-qqandroid-*-all.jar"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ local.properties
keys.properties
/plugins/

token.txt
token.txt
bintray.user.txt
bintray.key.txt
79 changes: 79 additions & 0 deletions buildSrc/src/main/kotlin/upload/Bintray.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package upload

import org.gradle.api.Project
import org.gradle.kotlin.dsl.provideDelegate
import java.io.File

/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
object Bintray {

@JvmStatic
fun getUser(project: Project): String {
kotlin.runCatching {
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
val bintray_user: String by project
return bintray_user
}

System.getProperty("bintray_user", null)?.let {
return it.trim()
}

File(File(System.getProperty("user.dir")).parent, "/bintray.user.txt").let { local ->
if (local.exists()) {
return local.readText().trim()
}
}

File(File(System.getProperty("user.dir")), "/bintray.user.txt").let { local ->
if (local.exists()) {
return local.readText().trim()
}
}

error(
"Cannot find bintray user, " +
"please specify by creating a file bintray.user.txt in project dir, " +
"or by providing JVM parameter 'bintray_user'"
)
}

@JvmStatic
fun getKey(project: Project): String {
kotlin.runCatching {
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
val bintray_key: String by project
return bintray_key
}

System.getProperty("bintray_key", null)?.let {
return it.trim()
}

File(File(System.getProperty("user.dir")).parent, "/bintray.key.txt").let { local ->
if (local.exists()) {
return local.readText().trim()
}
}

File(File(System.getProperty("user.dir")), "/bintray.key.txt").let { local ->
if (local.exists()) {
return local.readText().trim()
}
}

error(
"Cannot find bintray key, " +
"please specify by creating a file bintray.key.txt in project dir, " +
"or by providing JVM parameter 'bintray_key'"
)
}

}
104 changes: 0 additions & 104 deletions gradle/publish-japt.gradle

This file was deleted.

14 changes: 6 additions & 8 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import upload.Bintray

// 部分源码来自 kotlinx.coroutines
// Source code from kotlinx.coroutines

Expand All @@ -22,12 +24,8 @@ def pomConfig = {
}

bintray {
def keyProps = new Properties()
def keyFile = file("../keys.properties")
if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }

user = keyProps.getProperty("bintrayUser")
key = keyProps.getProperty("bintrayKey")
user = Bintray.getUser(project)
key = Bintray.getKey(project)

pkg {
repo = 'mirai'
Expand Down Expand Up @@ -67,14 +65,14 @@ bintrayUpload.dependsOn {
list
}

try{
try {

// empty xxx-javadoc.jar
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
}

} catch (Exception e){
} catch (Exception ignored) {

}
publishing {
Expand Down

0 comments on commit 40c22f4

Please sign in to comment.