diff --git a/buildSrc/src/main/kotlin/mikbot-publishing.gradle.kts b/buildSrc/src/main/kotlin/mikbot-publishing.gradle.kts index 94139769..95c44473 100644 --- a/buildSrc/src/main/kotlin/mikbot-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/mikbot-publishing.gradle.kts @@ -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("maven") { - groupId = "dev.schlaubi" - artifactId = "mikbot-${project.name}" - afterEvaluate { - version = project.version as String - } + create("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://git@github.com: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://git@github.com:DRSchlaubi/mikmusic.git" + url = "https://github.com/DRSchlaubi/mikmusic.git" + } } repositories { @@ -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"]) } } diff --git a/music/api/types/build.gradle.kts b/music/api/types/build.gradle.kts index d6bae917..a943c0c3 100644 --- a/music/api/types/build.gradle.kts +++ b/music/api/types/build.gradle.kts @@ -1,7 +1,10 @@ +import java.util.* + plugins { kotlin("multiplatform") alias(libs.plugins.kotlinx.serialization) - `mikbot-publishing` + `maven-publish` + signing } kotlin { @@ -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("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"]) + } +}