Skip to content

Commit

Permalink
Fix publishing for api types
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Dec 7, 2024
1 parent be523db commit d42a3c1
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 43 deletions.
83 changes: 41 additions & 42 deletions buildSrc/src/main/kotlin/mikbot-publishing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,58 @@ plugins {
com.google.cloud.artifactregistry.`gradle-plugin`
}

val sourcesJar by tasks.creating(Jar::class) {
dependsOn(tasks.processResources)
archiveClassifier = "sources"
destinationDirectory = layout.buildDirectory
from(sourceSets["main"].allSource)
}

publishing {
publications {
if (plugins.hasPlugin("org.jetbrains.kotlin.jvm")) {
create<MavenPublication>("maven") {
groupId = "dev.schlaubi"
artifactId = "mikbot-${project.name}"
afterEvaluate {
version = project.version as String
}
create<MavenPublication>("maven") {
groupId = "dev.schlaubi"
artifactId = "mikbot-${project.name}"
afterEvaluate {
version = project.version as String
}

from(components["java"])
val sourcesJar by tasks.creating(Jar::class) {
dependsOn(tasks.processResources)
archiveClassifier = "sources"
destinationDirectory = layout.buildDirectory
from(sourceSets["main"].allSource)
}
artifact(sourcesJar)
from(components["java"])
artifact(sourcesJar)

pom {
name = "mikbot"
description = "A modular framework for building Discord bots"
url = "https://github.com/DRSchlaubi/mikmusic"

organization {
name = "Schlaubi"
url = "https://github.com/DRSchlaubi"
}
pom {
name = "mikbot"
description = "A modular framework for building Discord bots"
url = "https://github.com/DRSchlaubi/mikmusic"

developers {
developer {
name = "Michael Rittmeister"
}
}
organization {
name = "Schlaubi"
url = "https://github.com/DRSchlaubi"
}

issueManagement {
system = "GitHub"
url = "https://github.com/DRSchlaubi/mikmusic/issues"
developers {
developer {
name = "Michael Rittmeister"
}
}

licenses {
license {
name = "Apache 2.0"
url = "https://opensource.org/licenses/Apache-2.0"
}
}
scm {
connection = "scm:git:https://github.com/DRSchlaubi/mikmusic.git"
developerConnection = "scm:git:ssh://[email protected]:DRSchlaubi/mikmusic.git"
url = "https://github.com/DRSchlaubi/mikmusic.git"
issueManagement {
system = "GitHub"
url = "https://github.com/DRSchlaubi/mikmusic/issues"
}

licenses {
license {
name = "Apache 2.0"
url = "https://opensource.org/licenses/Apache-2.0"
}
}
scm {
connection = "scm:git:https://github.com/DRSchlaubi/mikmusic.git"
developerConnection = "scm:git:ssh://[email protected]:DRSchlaubi/mikmusic.git"
url = "https://github.com/DRSchlaubi/mikmusic.git"
}
}

repositories {
Expand All @@ -85,6 +84,6 @@ signing {
val signingPassword = System.getenv("SIGNING_KEY_PASSWORD")?.toString()
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(String(Base64.getDecoder().decode(signingKey)), signingPassword)
publishing.publications.forEach { sign(it) }
sign(publishing.publications["maven"])
}
}
31 changes: 30 additions & 1 deletion music/api/types/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import java.util.*

plugins {
kotlin("multiplatform")
alias(libs.plugins.kotlinx.serialization)
`mikbot-publishing`
`maven-publish`
signing
}

kotlin {
Expand All @@ -19,3 +22,29 @@ kotlin {
}
}
}

publishing {
repositories {
maven("artifactregistry://europe-west3-maven.pkg.dev/mik-music/mikbot") {
credentials {
username = "_json_key_base64"
password = System.getenv("GOOGLE_KEY")?.toByteArray()?.let {
Base64.getEncoder().encodeToString(it)
}
}

authentication {
create<BasicAuthentication>("basic")
}
}
}
}

signing {
val signingKey = System.getenv("SIGNING_KEY")?.toString()
val signingPassword = System.getenv("SIGNING_KEY_PASSWORD")?.toString()
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(String(Base64.getDecoder().decode(signingKey)), signingPassword)
sign(publishing.publications["maven"])
}
}

0 comments on commit d42a3c1

Please sign in to comment.