Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve publishing #854

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/deployment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
java-version: 11
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
Expand All @@ -40,8 +40,8 @@ jobs:
!contains(github.event.head_commit.message, '[publish skip]') && github.event_name != 'pull_request' && github.ref != 'refs/heads/master'
env:
KORD_TEST_TOKEN: ${{ secrets.KORD_TEST_TOKEN }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.NEXUS_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.NEXUS_PASSWORD }}
SIGNING_KEY: ${{ secrets.signingKey }}
SIGNING_PASSWORD: ${{ secrets.signingPassword }}
steps:
Expand All @@ -52,7 +52,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
java-version: 11
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
10 changes: 5 additions & 5 deletions bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import com.vanniktech.maven.publish.JavaPlatform

plugins {
`java-platform`
`maven-publish`
id("com.vanniktech.maven.publish.base")
}

val me = project
Expand All @@ -26,10 +28,8 @@ dependencies {
}
}

publishing {
publications.register<MavenPublication>(Library.name) {
from(components["javaPlatform"])
}
mavenPublishing {
configure(JavaPlatform())
}

apply(plugin = "kord-publishing")
11 changes: 5 additions & 6 deletions buildSrc/src/main/kotlin/kord-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Expand All @@ -8,7 +10,7 @@ plugins {
`kotlinx-atomicfu`
org.jetbrains.kotlinx.`binary-compatibility-validator`
com.google.devtools.ksp
`maven-publish`
id("com.vanniktech.maven.publish.base")
}

repositories {
Expand Down Expand Up @@ -51,9 +53,6 @@ tasks {
}
}

publishing {
publications.register<MavenPublication>(Library.name) {
from(components["java"])
artifact(tasks.kotlinSourcesJar)
}
mavenPublishing {
configure(KotlinJvm(javadocJar = JavadocJar.Dokka("dokkaHtml")))
}
7 changes: 7 additions & 0 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest

Expand All @@ -8,6 +10,7 @@ plugins {
`kotlinx-atomicfu`
org.jetbrains.kotlinx.`binary-compatibility-validator`
com.google.devtools.ksp
id("com.vanniktech.maven.publish.base")
}

repositories {
Expand Down Expand Up @@ -92,3 +95,7 @@ tasks {
dependsOn("kspCommonMainKotlinMetadata")
}
}

mavenPublishing {
configure(KotlinMultiplatform(javadocJar = JavadocJar.Dokka("dokkaHtml")))
}
101 changes: 41 additions & 60 deletions buildSrc/src/main/kotlin/kord-publishing.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,79 +1,60 @@
import java.lang.System.getenv
import java.util.Base64

plugins {
`maven-publish`
// For some reason, Gradle does not generate an accessor for this
id("com.vanniktech.maven.publish.base")
signing
}

fun MavenPublication.registerDokkaJar() =
tasks.register<Jar>("${name}DokkaJar") {
archiveClassifier = "javadoc"
destinationDirectory = destinationDirectory.get().dir(name)
from(tasks.named("dokkaHtml"))
}

publishing {
publications {
withType<MavenPublication>().configureEach {
if (project.name != "bom") artifact(registerDokkaJar())

groupId = Library.group
artifactId = "kord-$artifactId"
version = libraryVersion
group = Library.group
version = libraryVersion

pom {
name = Library.name
description = Library.description
url = Library.projectUrl

organization {
name = "Kord"
url = "https://github.com/kordlib"
}
signing {
val secretKey = System.getenv("SIGNING_KEY")?.let { String(Base64.getDecoder().decode(it)) }
val password = System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(secretKey, password)
sign(publishing.publications)
}

developers {
developer {
name = "The Kord Team"
}
}
mavenPublishing {
coordinates(Library.group, "kord-${project.name}", libraryVersion)
// This sets up OSSRH snapshots + maven central
publishToMavenCentral(automaticRelease = true)
signAllPublications()

issueManagement {
system = "GitHub"
url = "https://github.com/kordlib/kord/issues"
}
pom {
name = Library.name
description = Library.description
url = Library.projectUrl

licenses {
license {
name = "MIT"
url = "https://opensource.org/licenses/MIT"
}
}
organization {
name = "Kord"
url = "https://github.com/kordlib"
}

scm {
connection = "scm:git:ssh://github.com/kordlib/kord.git"
developerConnection = "scm:git:ssh://[email protected]:kordlib/kord.git"
url = Library.projectUrl
}
developers {
developer {
name = "The Kord Team"
}
}
}

repositories {
maven {
url = uri(if (isRelease) Repo.releasesUrl else Repo.snapshotsUrl)
issueManagement {
system = "GitHub"
url = "https://github.com/kordlib/kord/issues"
}

credentials {
username = getenv("NEXUS_USER")
password = getenv("NEXUS_PASSWORD")
licenses {
license {
name = "MIT"
url = "https://opensource.org/licenses/MIT"
distribution = "https://github.com/kordlib/kord/blob/LICENSE"
}
}
}
}

signing {
val secretKey = getenv("SIGNING_KEY")?.let { String(Base64.getDecoder().decode(it)) }
val password = getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(secretKey, password)
sign(publishing.publications)
scm {
connection = "scm:git:ssh://github.com/kordlib/kord.git"
developerConnection = "scm:git:ssh://[email protected]:kordlib/kord.git"
url = Library.projectUrl
}
}
}
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dokka = "1.8.20" # https://github.com/Kotlin/dokka
kotlinx-atomicfu = "0.21.0" # https://github.com/Kotlin/kotlinx-atomicfu
binary-compatibility-validator = "0.13.2" # https://github.com/Kotlin/binary-compatibility-validator
buildconfig = "4.1.2" # https://github.com/gmazzo/gradle-buildconfig-plugin
maven-publish-plugin = "0.25.3"


[libraries]
Expand Down Expand Up @@ -84,7 +85,7 @@ dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref
atomicfu-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "kotlinx-atomicfu" }
binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }

maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish-plugin" }

[bundles]

Expand All @@ -101,6 +102,7 @@ pluginsForBuildSrc = [
"atomicfu-plugin",
"binary-compatibility-validator-plugin",
"ksp-plugin",
"maven-publish-plugin"
]


Expand Down