Skip to content

Commit 78c5fe7

Browse files
committed
CI: Migrate to com.vanniktech.maven.publish plugin
1 parent 549b44d commit 78c5fe7

File tree

4 files changed

+51
-62
lines changed

4 files changed

+51
-62
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ jobs:
7878

7979
- name: Release to sonatype
8080
env:
81-
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
82-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
83-
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
84-
GPG_KEY_SECRET: ${{ secrets.GPG_KEY_SECRET }}
81+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}
82+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
83+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}
84+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_SECRET }}
8585
PACKAGE_VERSION: ${{ github.event.release.tag_name }}
86-
run: ./gradlew publishJsPublicationToMavenRepository
86+
run: ./gradlew publishToMavenCentral --debug
8787

8888
publish:
8989
if: ${{ github.event_name == 'release' }}

build.gradle.kts

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ plugins {
1010
alias(libs.plugins.detekt)
1111
alias(libs.plugins.dokka)
1212
alias(libs.plugins.kover)
13+
alias(libs.plugins.maven.publish)
1314
alias(libs.plugins.sqldelight)
14-
id("maven-publish")
1515
id("signing")
1616
}
1717

1818
val defaultGroupId = "cz.sazel.sqldelight"
19+
val nameStr = "node-sqlite3-driver"
1920
val versionBase = "0.5.0"
2021

2122
val localProperties = Properties().apply {
@@ -99,7 +100,7 @@ kotlin {
99100
publicationsFromMainHost = listOf(js()).map { it.name } + "kotlinMultiplatform"
100101

101102
dokka {
102-
moduleName = "node-sqlite3-driver"
103+
moduleName = nameStr
103104
moduleVersion = versionStr
104105

105106
dokkaSourceSets {
@@ -119,47 +120,7 @@ val javadocJar = tasks.register<Jar>("javadocJar") {
119120
from(layout.buildDirectory.dir("dokka/html"))
120121
}
121122

122-
publishing {
123-
publications {
124-
matching { it.name in publicationsFromMainHost }.all {
125-
val targetPublication = this@all
126-
tasks.withType<AbstractPublishToMaven>().matching { it.publication == targetPublication }
127-
.configureEach { onlyIf { findProperty("isMainHost") == "true" } }
128-
}
129-
130-
131-
withType<MavenPublication> {
132-
artifact(javadocJar)
133-
134-
pom {
135-
name.set("node-sqlite3-driver")
136-
description.set("Driver for the library SQLDelight that supports sqlite3 Node.js module")
137-
licenses {
138-
license {
139-
name.set("Apache-2.0")
140-
url.set("https://opensource.org/licenses/Apache-2.0")
141-
}
142-
}
143-
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
144-
issueManagement {
145-
system.set("Github")
146-
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver/issues")
147-
}
148-
scm {
149-
connection.set("https://github.com/wojta/sqldelight-node-sqlite3-driver.git")
150-
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
151-
}
152-
developers {
153-
developer {
154-
name.set("Vojtěch Sázel")
155-
email.set("sqldelight@sazel.cz")
156-
}
157-
}
158-
}
159-
}
160-
161-
}
162-
123+
mavenPublishing {
163124
repositories {
164125
val githubUserName = System.getenv("GITHUB_USER") ?: localProperties["github.user"] as String?
165126
if (githubUserName != null) { // Github packages repo
@@ -174,30 +135,55 @@ publishing {
174135
}
175136
}
176137
}
177-
maven { // OSS Sonatype (default)
178-
val isSnapshot = version.toString().endsWith("SNAPSHOT")
179-
val destination = if (!isSnapshot) {
180-
"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
181-
} else "https://central.sonatype.com/repository/maven-snapshots/"
182-
url = uri(destination)
138+
mavenCentral {
183139
credentials {
184140
username = System.getenv("SONATYPE_USER") ?: localProperties["sonatype.user"] as String?
185141
password = System.getenv("SONATYPE_PASSWORD") ?: localProperties["sonatype.password"] as String?
186142
}
187143
}
188144
mavenLocal()
189145
}
190-
}
146+
coordinates(group.toString(), nameStr, versionStr)
147+
148+
signing {
149+
useInMemoryPgpKeys(
150+
System.getenv("GPG_KEY_SECRET") ?: localProperties["gpg.keySecret"] as String?,
151+
System.getenv("GPG_KEY_PASSWORD") ?: localProperties["gpg.keyPassword"] as String?
152+
)
153+
sign(publishing.publications)
154+
}
191155

192-
signing {
193-
useInMemoryPgpKeys(
194-
System.getenv("GPG_KEY_SECRET") ?: localProperties["gpg.keySecret"] as String?,
195-
System.getenv("GPG_KEY_PASSWORD") ?: localProperties["gpg.keyPassword"] as String?
196-
)
156+
// publish to Maven Central
157+
publishToMavenCentral()
197158

198-
sign(publishing.publications)
159+
pom {
160+
name.set("node-sqlite3-driver")
161+
description.set("Driver for the library SQLDelight that supports sqlite3 Node.js module")
162+
licenses {
163+
license {
164+
name.set("Apache-2.0")
165+
url.set("https://opensource.org/licenses/Apache-2.0")
166+
}
167+
}
168+
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
169+
issueManagement {
170+
system.set("Github")
171+
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver/issues")
172+
}
173+
scm {
174+
connection.set("https://github.com/wojta/sqldelight-node-sqlite3-driver.git")
175+
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
176+
}
177+
developers {
178+
developer {
179+
name.set("Vojtěch Sázel")
180+
email.set("sqldelight@sazel.cz")
181+
}
182+
}
183+
}
199184
}
200185

186+
201187
// workaround for missing sqlite3 bindings
202188
val bindingsInstall = tasks.register("sqlite3BindingsInstall") {
203189
doFirst {
@@ -225,7 +211,7 @@ detekt {
225211
buildUponDefaultConfig = true // preconfigure defaults
226212
allRules = false // activate all available (even unstable) rules.
227213
config.setFrom("$projectDir/gradle/detekt/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
228-
// baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt
214+
// baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt
229215

230216
reports {
231217
html.required.set(true) // observe findings in your browser with structure and code snippets

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
kotlin.code.style=official
22
kotlin.js.generate.executable.default=false
33
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
4+
signAllPublications=true

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ kotlinCoroutines = "1.10.2"
66
kover = "0.9.1"
77
node-sqlite3 = "5.1.7"
88
node-js = "22.13.0"
9+
maven-publish = "0.34.0"
910
sqldelight = "2.1.0"
1011

1112
[libraries]
@@ -20,3 +21,4 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
2021
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
2122
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
2223
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
24+
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }

0 commit comments

Comments
 (0)