-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22a2089
commit 78025fb
Showing
4 changed files
with
161 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Publish To Maven Central | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | ||
|
||
- name: Add permissons | ||
run: chmod +x gradlew | ||
|
||
- name: Publish to central | ||
run: ./gradlew clean sonatypeCentralUpload -xtest | ||
env: | ||
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | ||
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} | ||
CENTRAL_PRIVATE_KEY: ${{ secrets.CENTRAL_PRIVATE_KEY }} | ||
CENTRAL_PRIVATE_KEY_PWD: ${{ secrets.CENTRAL_PRIVATE_KEY_PWD }} | ||
CENTRAL_PUBLIC_KEY: ${{ secrets.CENTRAL_PUBLIC_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("net.kyori:indra-common:3.1.3") | ||
implementation("cl.franciscosolis.sonatype-central-upload:cl.franciscosolis.sonatype-central-upload.gradle.plugin:1.0.3") | ||
} |
114 changes: 114 additions & 0 deletions
114
buildSrc/src/main/kotlin/publish-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import groovy.util.Node | ||
import groovy.util.NodeList | ||
|
||
plugins { | ||
`maven-publish` | ||
`java-library` | ||
id("net.kyori.indra") | ||
id("net.kyori.indra.publishing") | ||
id("cl.franciscosolis.sonatype-central-upload") | ||
} | ||
|
||
indra { | ||
github("SNWCreations", "JKook") { | ||
ci(true) | ||
} | ||
apache2License() | ||
|
||
javaVersions { | ||
target(8) | ||
minimumToolchain(17) | ||
} | ||
|
||
configurePublications { | ||
pom { | ||
url = "https://github.com/SNWCreations/JKook" | ||
description = "The Kook (https://kookapp.cn) Bot's Plugin framework for Java." | ||
developers { | ||
developer { | ||
id = "SNWCreations" | ||
name = "SNWCreations" | ||
email = "[email protected]" | ||
roles = listOf("contributor") | ||
} | ||
developer { | ||
id = "huanmeng-qwq" | ||
name = "huanmeng_qwq" | ||
email = "[email protected]" | ||
roles = listOf("contributor") | ||
} | ||
developer { | ||
id = "xiaoACE6716" | ||
name = "xiaoACE" | ||
roles = listOf("contributor") | ||
} | ||
developer { | ||
id = "RealSeek" | ||
name = "RealSeek" | ||
roles = listOf("contributor") | ||
} | ||
developer { | ||
id = "gehongyan" | ||
name = "Ge" | ||
roles = listOf("contributor") | ||
} | ||
developer { | ||
id = "DeeChael" | ||
name = "Deerio Chaelingo" | ||
roles = listOf("contributor") | ||
} | ||
developer { | ||
id = "natholdallas" | ||
name = "natholdallas" | ||
roles = listOf("contributor") | ||
} | ||
} | ||
withXml { | ||
project.configurations.compileOnly.get().allDependencies.forEach { dep -> | ||
((asNode().get("dependencies") as NodeList)[0] as Node).appendNode("dependency").apply { | ||
appendNode("groupId", dep.group) | ||
appendNode("artifactId", dep.name) | ||
appendNode("version", dep.version) | ||
appendNode("scope", "provided") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
options.compilerArgs = mutableListOf("-Xlint:-deprecation,-unchecked") | ||
} | ||
|
||
val cleanUpload by tasks.creating(Delete::class) { | ||
setDelete(project.files(project.layout.buildDirectory.dir("sonatype-central-upload"))) | ||
} | ||
|
||
tasks.sonatypeCentralUpload { | ||
// gradle sonatypeCentralUpload -PCENTRAL_USERNAME=<username> -PCENTRAL_PASSWORD=<password> -PCENTRAL_PRIVATE_KEY=<privateKey> -PCENTRAL_PRIVATE_KEY_PWD=<privateKeyPwd> -PCENTRAL_PUBLIC_KEY=<publicKey> | ||
val centralUsername = System.getenv("CENTRAL_USERNAME") ?: findProperty("CENTRAL_USERNAME")?.toString() | ||
val centralPassword = System.getenv("CENTRAL_PASSWORD") ?: findProperty("CENTRAL_PASSWORD")?.toString() | ||
val privateKey = System.getenv("CENTRAL_PRIVATE_KEY") ?: findProperty("CENTRAL_PRIVATE_KEY")?.toString() | ||
val privateKeyPwd = System.getenv("CENTRAL_PRIVATE_KEY_PWD") ?: findProperty("CENTRAL_PRIVATE_KEY_PWD")?.toString() | ||
val publicKey = System.getenv("CENTRAL_PUBLIC_KEY") ?: findProperty("CENTRAL_PUBLIC_KEY")?.toString() | ||
dependsOn(tasks.build, tasks.generatePomFileForMavenPublication, cleanUpload) | ||
// this.username = centralUsername | ||
// this.password = centralPassword | ||
this.publishingType = "AUTOMATIC" // MANUAL | ||
this.signingKey = privateKey | ||
this.signingKeyPassphrase = privateKeyPwd | ||
this.publicKey = publicKey | ||
archives = project.layout.buildDirectory.dir("libs").get().asFileTree | ||
pom = file(project.layout.buildDirectory.file("publications/maven/pom-default.xml")) | ||
} | ||
|
||
tasks.test { | ||
onlyIf { !gradle.startParameter.taskNames.contains("sonatypeCentralUpload") } | ||
} | ||
|
||
project.afterEvaluate { | ||
tasks.findByName("shadowJar")?.apply { | ||
onlyIf { !gradle.startParameter.taskNames.contains("sonatypeCentralUpload") } | ||
} | ||
} |