Skip to content

Commit 8c87d79

Browse files
committed
build: move to vanniktech plugin for publishing to Central
1 parent 28548e3 commit 8c87d79

File tree

5 files changed

+62
-122
lines changed

5 files changed

+62
-122
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ on:
55
tags:
66
- 'v*'
77
env:
8-
GPG_SEC: ${{ secrets.PGP_SEC }}
9-
GPG_PASSWORD: ${{ secrets.PGP_PASSWORD }}
10-
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
11-
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
8+
# TODO: required to use the in-memory PGP key.
9+
# See https://github.com/vanniktech/gradle-maven-publish-plugin/issues/253#issuecomment-841637159
10+
# ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.PGP_KEY_ID }}
11+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.PGP_SEC }}
12+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_PASSWORD }}
13+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}
14+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
1215

1316
jobs:
1417
release:
@@ -35,4 +38,4 @@ jobs:
3538
with:
3639
gradle-version: wrapper
3740
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
38-
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
41+
- run: ./gradlew publishToMavenCentral

build.gradle.kts

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import io.github.petertrr.configurePublishing
2-
import io.github.petertrr.ext.booleanProperty
31
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
42
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
53
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
@@ -8,6 +6,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
86
plugins {
97
kotlin("multiplatform")
108
alias(libs.plugins.detekt)
9+
alias(libs.plugins.vanniktech)
1110
id("jacoco-convention")
1211
}
1312

@@ -116,7 +115,57 @@ kotlin {
116115
}
117116
}
118117

119-
configurePublishing()
118+
mavenPublishing {
119+
coordinates(
120+
groupId = project.group.toString(),
121+
artifactId = project.name,
122+
version = project.version.toString(),
123+
)
124+
125+
// Publishing to Maven Central requires the following Gradle properties:
126+
// mavenCentralUsername=central_username
127+
// mavenCentralPassword=central_password
128+
publishToMavenCentral()
129+
130+
// Signing is enabled only if the key is actually provided.
131+
// We do not want missing signing info to block publication to local.
132+
val signingKey = project.providers.gradleProperty("signingInMemoryKey")
133+
134+
if (signingKey.isPresent) {
135+
// Signing requires the following Gradle properties:
136+
// signingInMemoryKeyId=pgp_key_id
137+
// signingInMemoryKey=pgp_key
138+
// signingInMemoryKeyPassword=pgp_key_password
139+
signAllPublications()
140+
}
141+
142+
pom {
143+
name.set(project.name)
144+
description.set(project.description)
145+
url.set("https://github.com/petertrr/kotlin-multiplatform-diff")
146+
147+
licenses {
148+
license {
149+
name.set("The Apache Software License, Version 2.0")
150+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
151+
distribution.set("repo")
152+
}
153+
}
154+
155+
developers {
156+
developer {
157+
id.set("petertrr")
158+
name.set("Petr Trifanov")
159+
email.set("peter.trifanov@mail.ru")
160+
}
161+
}
162+
163+
scm {
164+
url.set("https://github.com/petertrr/kotlin-multiplatform-diff")
165+
connection.set("scm:git:git://github.com/petertrr/kotlin-multiplatform-diff.git")
166+
}
167+
}
168+
}
120169

121170
detekt {
122171
buildUponDefaultConfig = true

buildSrc/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ plugins {
44

55
dependencies {
66
implementation(libs.dokka.plugin)
7-
implementation(libs.nexus.plugin)
87
implementation(libs.kotlin.plugin)
98
}

buildSrc/src/main/kotlin/io/github/petertrr/PublishingConfiguration.kt

Lines changed: 0 additions & 111 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
kotlin = "2.2.20-RC2"
33
detekt = "1.23.8"
44
dokka = "2.1.0-Beta"
5-
nexus = "2.0.0"
5+
vanniktech = "0.34.0"
66

77
[plugins]
88
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
9+
vanniktech = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" }
910

1011
[libraries]
1112
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }
1213

1314
# Gradle plugins
1415
kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
1516
dokka-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" }
16-
nexus-plugin = { group = "io.github.gradle-nexus", name = "publish-plugin", version.ref = "nexus" }

0 commit comments

Comments
 (0)