From 1f6e01e2abd53019643e39b4eab4a91f9550329a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20S=C3=A1zel?= Date: Sun, 19 Oct 2025 19:41:54 +0200 Subject: [PATCH 1/2] Revert "CI: fix SonaType Maven Central (attempt 2)" This reverts commit 483828cba2bc3f6bf41de898d6141d31e003dcc6. --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 52bb25e..61dee6f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -177,7 +177,7 @@ publishing { maven { // OSS Sonatype (default) val isSnapshot = version.toString().endsWith("SNAPSHOT") val destination = if (!isSnapshot) { - "https://ossrh-staging-api.central.sonatype.com/service/local/" + "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/" } else "https://central.sonatype.com/repository/maven-snapshots/" url = uri(destination) credentials { From 2f30fe95cee818106494218972e7005eb992a490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20S=C3=A1zel?= Date: Sun, 19 Oct 2025 20:27:38 +0200 Subject: [PATCH 2/2] CI: Migrate to com.vanniktech.maven.publish plugin --- .github/workflows/build.yml | 10 ++-- build.gradle.kts | 100 ++++++++++++++++-------------------- gradle.properties | 1 + gradle/libs.versions.toml | 2 + 4 files changed, 51 insertions(+), 62 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad317a7..7d67a27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,12 +78,12 @@ jobs: - name: Release to sonatype env: - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }} - GPG_KEY_SECRET: ${{ secrets.GPG_KEY_SECRET }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_SECRET }} PACKAGE_VERSION: ${{ github.event.release.tag_name }} - run: ./gradlew publishJsPublicationToMavenRepository + run: ./gradlew publishToMavenCentral --debug publish: if: ${{ github.event_name == 'release' }} diff --git a/build.gradle.kts b/build.gradle.kts index 61dee6f..5daa064 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,12 +10,13 @@ plugins { alias(libs.plugins.detekt) alias(libs.plugins.dokka) alias(libs.plugins.kover) + alias(libs.plugins.maven.publish) alias(libs.plugins.sqldelight) - id("maven-publish") id("signing") } val defaultGroupId = "cz.sazel.sqldelight" +val nameStr = "node-sqlite3-driver" val versionBase = "0.5.0" val localProperties = Properties().apply { @@ -99,7 +100,7 @@ kotlin { publicationsFromMainHost = listOf(js()).map { it.name } + "kotlinMultiplatform" dokka { - moduleName = "node-sqlite3-driver" + moduleName = nameStr moduleVersion = versionStr dokkaSourceSets { @@ -119,47 +120,7 @@ val javadocJar = tasks.register("javadocJar") { from(layout.buildDirectory.dir("dokka/html")) } -publishing { - publications { - matching { it.name in publicationsFromMainHost }.all { - val targetPublication = this@all - tasks.withType().matching { it.publication == targetPublication } - .configureEach { onlyIf { findProperty("isMainHost") == "true" } } - } - - - withType { - artifact(javadocJar) - - pom { - name.set("node-sqlite3-driver") - description.set("Driver for the library SQLDelight that supports sqlite3 Node.js module") - licenses { - license { - name.set("Apache-2.0") - url.set("https://opensource.org/licenses/Apache-2.0") - } - } - url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver") - issueManagement { - system.set("Github") - url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver/issues") - } - scm { - connection.set("https://github.com/wojta/sqldelight-node-sqlite3-driver.git") - url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver") - } - developers { - developer { - name.set("Vojtěch Sázel") - email.set("sqldelight@sazel.cz") - } - } - } - } - - } - +mavenPublishing { repositories { val githubUserName = System.getenv("GITHUB_USER") ?: localProperties["github.user"] as String? if (githubUserName != null) { // Github packages repo @@ -174,12 +135,7 @@ publishing { } } } - maven { // OSS Sonatype (default) - val isSnapshot = version.toString().endsWith("SNAPSHOT") - val destination = if (!isSnapshot) { - "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/" - } else "https://central.sonatype.com/repository/maven-snapshots/" - url = uri(destination) + mavenCentral { credentials { username = System.getenv("SONATYPE_USER") ?: localProperties["sonatype.user"] as String? password = System.getenv("SONATYPE_PASSWORD") ?: localProperties["sonatype.password"] as String? @@ -187,17 +143,47 @@ publishing { } mavenLocal() } -} + coordinates(group.toString(), nameStr, versionStr) + + signing { + useInMemoryPgpKeys( + System.getenv("GPG_KEY_SECRET") ?: localProperties["gpg.keySecret"] as String?, + System.getenv("GPG_KEY_PASSWORD") ?: localProperties["gpg.keyPassword"] as String? + ) + sign(publishing.publications) + } -signing { - useInMemoryPgpKeys( - System.getenv("GPG_KEY_SECRET") ?: localProperties["gpg.keySecret"] as String?, - System.getenv("GPG_KEY_PASSWORD") ?: localProperties["gpg.keyPassword"] as String? - ) + // publish to Maven Central + publishToMavenCentral() - sign(publishing.publications) + pom { + name.set("node-sqlite3-driver") + description.set("Driver for the library SQLDelight that supports sqlite3 Node.js module") + licenses { + license { + name.set("Apache-2.0") + url.set("https://opensource.org/licenses/Apache-2.0") + } + } + url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver") + issueManagement { + system.set("Github") + url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver/issues") + } + scm { + connection.set("https://github.com/wojta/sqldelight-node-sqlite3-driver.git") + url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver") + } + developers { + developer { + name.set("Vojtěch Sázel") + email.set("sqldelight@sazel.cz") + } + } + } } + // workaround for missing sqlite3 bindings val bindingsInstall = tasks.register("sqlite3BindingsInstall") { doFirst { @@ -225,7 +211,7 @@ detekt { buildUponDefaultConfig = true // preconfigure defaults allRules = false // activate all available (even unstable) rules. config.setFrom("$projectDir/gradle/detekt/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior - // baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt +// baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt reports { html.required.set(true) // observe findings in your browser with structure and code snippets diff --git a/gradle.properties b/gradle.properties index ed69e2e..a09a23e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ kotlin.code.style=official kotlin.js.generate.executable.default=false org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled +signAllPublications=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 85d55ed..8179ffd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,6 +6,7 @@ kotlinCoroutines = "1.10.2" kover = "0.9.1" node-sqlite3 = "5.1.7" node-js = "22.13.0" +maven-publish = "0.34.0" sqldelight = "2.1.0" [libraries] @@ -20,3 +21,4 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" } +maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }