Skip to content

Commit 3c05c9b

Browse files
committed
use gradle-maven-publish-plugin as it creates staging repository itself and doesn't rely on auto-staging
1 parent 3e466c9 commit 3c05c9b

File tree

6 files changed

+56
-100
lines changed

6 files changed

+56
-100
lines changed

.github/workflows/publish-release.yml

+6-14
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,10 @@ jobs:
1616
with:
1717
cache-disabled: true
1818

19-
- name: Publish to Maven Local (prepare packages)
20-
run: ./gradlew publishToMavenLocal -Pversion=${{ github.ref_name }} --no-configuration-cache
19+
- name: Publish release to Maven Central
20+
run: ./gradlew publishToMavenCentral -Pversion=${{ github.ref_name }} --no-configuration-cache
2121
env:
22-
ORG_GRADLE_PROJECT_signingKey: ${{secrets.signingKey}}
23-
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.signingPassword}}
24-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.sonatypeUsername}}
25-
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.sonatypePassword}}
26-
27-
- name: Publish release to Maven Central (version ${{ github.ref_name }})
28-
run: ./gradlew publishAllPublicationsToSonatypeRepository -Pversion=${{ github.ref_name }} --no-configuration-cache
29-
env:
30-
ORG_GRADLE_PROJECT_signingKey: ${{secrets.signingKey}}
31-
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.signingPassword}}
32-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.sonatypeUsername}}
33-
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.sonatypePassword}}
22+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.signingKey}}
23+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.signingPassword}}
24+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.sonatypeUsername}}
25+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.sonatypePassword}}

.github/workflows/publish-snapshot.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ jobs:
2727
branch_name="${ref_name////-}"
2828
echo "::set-output name=version-suffix::$branch_name"
2929
30-
- name: Publish to Maven Local (prepare packages)
31-
run: ./gradlew publishToMavenLocal -PversionSuffix=${{ steps.set-version.outputs.version-suffix }} -PgithubUsername=${{ github.actor }} -PgithubPassword=${{ github.token }} --no-configuration-cache
32-
33-
- name: Publish snapshot to Github Packages (version x.y.z-${{ steps.set-version.outputs.version-suffix }}-SNAPSHOT)
34-
run: ./gradlew publishAllPublicationsToGithubRepository -PversionSuffix=${{ steps.set-version.outputs.version-suffix }} -PgithubUsername=${{ github.actor }} -PgithubPassword=${{ github.token }} --no-configuration-cache
30+
- name: Publish snapshot to Maven Central
31+
run: ./gradlew publishToMavenCentral -Pversion=0.16.0-${{ steps.set-version.outputs.version-suffix }}-SNAPSHOT --no-configuration-cache
32+
env:
33+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.signingKey}}
34+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.signingPassword}}
35+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.sonatypeUsername}}
36+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.sonatypePassword}}

build-logic/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ dependencies {
2222
implementation(libs.kotlin.gradle.plugin)
2323
implementation(libs.kotlinx.bcv.gradle.plugin)
2424
implementation(libs.kotlinx.atomicfu.gradle.plugin)
25+
implementation(libs.maven.publish.gradle.plugin)
2526
}

build-logic/src/main/kotlin/rsocketbuild.publication.gradle.kts

+38-80
Original file line numberDiff line numberDiff line change
@@ -14,96 +14,54 @@
1414
* limitations under the License.
1515
*/
1616

17-
plugins {
18-
`maven-publish`
19-
signing
20-
}
21-
22-
val githubUsername: String? by project
23-
val githubPassword: String? by project
24-
25-
val sonatypeUsername: String? by project
26-
val sonatypePassword: String? by project
27-
28-
val signingKey: String? by project
29-
val signingPassword: String? by project
17+
import com.vanniktech.maven.publish.*
3018

31-
// TODO: refactor publication a bit, so that version in gradle.properties will not contain SNAPSHOT
32-
val versionSuffix = providers.gradleProperty("rsocketbuild.versionSuffix").orNull
33-
if (versionSuffix != null) {
34-
val versionString = project.version.toString()
35-
require(versionString.endsWith("-SNAPSHOT"))
36-
project.version = versionString.replace("-", "-${versionSuffix}-")
37-
println("Current version: ${project.version}")
19+
plugins {
20+
id("com.vanniktech.maven.publish.base")
3821
}
3922

40-
// empty javadoc for maven central
41-
val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") }
42-
43-
// this is somewhat a hack because we have a single javadoc artifact which is used for all publications
44-
tasks.withType<Sign>().configureEach { dependsOn(javadocJar) }
45-
tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) }
23+
mavenPublishing {
24+
publishToMavenCentral(SonatypeHost.S01)
25+
signAllPublications()
4626

47-
publishing {
48-
publications.withType<MavenPublication> {
49-
artifact(javadocJar)
50-
pom {
51-
name.set(project.name)
52-
description.set(provider {
53-
checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" }
54-
})
55-
url.set("http://rsocket.io")
27+
pom {
28+
name.set(project.name)
29+
description.set(provider {
30+
checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" }
31+
})
32+
url.set("https://rsocket.io")
5633

57-
licenses {
58-
license {
59-
name.set("The Apache Software License, Version 2.0")
60-
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
61-
distribution.set("repo")
62-
}
63-
}
64-
developers {
65-
developer {
66-
id.set("whyoleg")
67-
name.set("Oleg Yukhnevich")
68-
email.set("[email protected]")
69-
}
70-
developer {
71-
id.set("OlegDokuka")
72-
name.set("Oleh Dokuka")
73-
email.set("[email protected]")
74-
}
75-
}
76-
scm {
77-
connection.set("https://github.com/rsocket/rsocket-kotlin.git")
78-
developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git")
79-
url.set("https://github.com/rsocket/rsocket-kotlin")
34+
licenses {
35+
license {
36+
name.set("The Apache Software License, Version 2.0")
37+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
38+
distribution.set("repo")
8039
}
8140
}
82-
}
83-
84-
repositories {
85-
// TODO: drop github and use sonatype (?)
86-
maven {
87-
name = "github"
88-
url = uri("https://maven.pkg.github.com/rsocket/rsocket-kotlin")
89-
credentials {
90-
username = githubUsername
91-
password = githubPassword
41+
developers {
42+
developer {
43+
id.set("whyoleg")
44+
name.set("Oleg Yukhnevich")
45+
email.set("[email protected]")
9246
}
93-
}
94-
maven {
95-
name = "sonatype"
96-
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
97-
credentials {
98-
username = sonatypeUsername
99-
password = sonatypePassword
47+
developer {
48+
id.set("OlegDokuka")
49+
name.set("Oleh Dokuka")
50+
email.set("[email protected]")
10051
}
10152
}
53+
scm {
54+
connection.set("https://github.com/rsocket/rsocket-kotlin.git")
55+
developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git")
56+
url.set("https://github.com/rsocket/rsocket-kotlin")
57+
}
10258
}
10359
}
10460

105-
signing {
106-
isRequired = sonatypeUsername != null && sonatypePassword != null
107-
useInMemoryPgpKeys(signingKey, signingPassword)
108-
sign(publishing.publications)
109-
}
61+
// javadocJar setup
62+
// we have a single javadoc artifact which is used for all publications,
63+
// and so we need to manually create task dependencies to make Gradle happy
64+
val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") }
65+
tasks.withType<Sign>().configureEach { dependsOn(javadocJar) }
66+
tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) }
67+
publishing.publications.withType<MavenPublication>().configureEach { artifact(javadocJar) }

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
#
1616
group=io.rsocket.kotlin
17-
version=0.16.0-SNAPSHOT
17+
version=0.16.0
1818
#Kotlin
1919
kotlin.mpp.import.enableKgpDependencyResolution=true
2020
kotlin.native.ignoreDisabledTargets=true

gradle/libs.versions.toml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ rsocket-java = "1.1.3"
1414

1515
jmh = "1.36"
1616

17+
maven-publish = "0.28.0"
18+
1719
[libraries]
1820
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
1921
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
@@ -45,6 +47,7 @@ rsocket-java-transport-local = { module = 'io.rsocket:rsocket-transport-local',
4547
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
4648
kotlinx-atomicfu-gradle-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "kotlinx-atomicfu" }
4749
kotlinx-bcv-gradle-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "kotlinx-bcv" }
50+
maven-publish-gradle-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
4851

4952
[plugins]
5053
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }

0 commit comments

Comments
 (0)