Skip to content

Commit 7f4bd95

Browse files
committed
Update release workflow and Gradle configuration for Maven Central publishing
1 parent f9169b3 commit 7f4bd95

4 files changed

Lines changed: 35 additions & 55 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
distribution: temurin
1414
java-version: '25'
1515
- uses: gradle/actions/setup-gradle@v4
16-
- run: ./gradlew publish
16+
- run: ./gradlew publishAndReleaseToMavenCentral
1717
env:
18-
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
19-
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
20-
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
18+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_USERNAME }}
19+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PASSWORD }}
20+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
2121
RELEASE_VERSION: ${{ github.event.release.tag_name }}

client/build.gradle

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ plugins {
99
// Apply the java-library plugin for API and implementation separation.
1010
id 'java-library'
1111
id 'checkstyle'
12-
id 'maven-publish'
13-
id 'signing'
12+
id 'com.vanniktech.maven.publish'
1413
}
1514

1615
repositories {
@@ -121,57 +120,32 @@ tasks.withType(Checkstyle) {
121120
}
122121
}
123122

124-
group = 'com.rstmdb'
125-
126-
publishing {
127-
publications {
128-
mavenJava(MavenPublication) {
129-
groupId = 'com.rstmdb'
130-
artifactId = 'rstmdb-client'
131-
version = (System.getenv('RELEASE_VERSION') ?: '0.0.0-SNAPSHOT').replaceAll(/^v/, '')
132-
from components.java
133-
pom {
134-
name = 'rstmdb-client'
135-
description = 'Official Java client for rstmdb'
136-
url = 'https://github.com/rstmdb/rstmdb-java'
137-
licenses {
138-
license {
139-
name = 'MIT'
140-
url = 'https://opensource.org/licenses/MIT'
141-
}
142-
}
143-
developers {
144-
developer {
145-
name = 'rstmdb'
146-
url = 'https://github.com/rstmdb'
147-
}
148-
}
149-
scm {
150-
connection = 'scm:git:git://github.com/rstmdb/rstmdb-java.git'
151-
developerConnection = 'scm:git:ssh://github.com/rstmdb/rstmdb-java.git'
152-
url = 'https://github.com/rstmdb/rstmdb-java'
153-
}
123+
mavenPublishing {
124+
publishToMavenCentral()
125+
signAllPublications()
126+
127+
coordinates('com.rstmdb', 'rstmdb-client', (System.getenv('RELEASE_VERSION') ?: '0.0.0-SNAPSHOT').replaceAll(/^v/, ''))
128+
129+
pom {
130+
name = 'rstmdb-client'
131+
description = 'Official Java client for rstmdb'
132+
url = 'https://github.com/rstmdb/rstmdb-java'
133+
licenses {
134+
license {
135+
name = 'MIT'
136+
url = 'https://opensource.org/licenses/MIT'
154137
}
155138
}
156-
}
157-
158-
repositories {
159-
maven {
160-
name = 'ossrh-staging-api'
161-
url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
162-
credentials {
163-
username = System.getenv('CENTRAL_USERNAME')
164-
password = System.getenv('CENTRAL_PASSWORD')
139+
developers {
140+
developer {
141+
name = 'rstmdb'
142+
url = 'https://github.com/rstmdb'
165143
}
166144
}
145+
scm {
146+
connection = 'scm:git:git://github.com/rstmdb/rstmdb-java.git'
147+
developerConnection = 'scm:git:ssh://github.com/rstmdb/rstmdb-java.git'
148+
url = 'https://github.com/rstmdb/rstmdb-java'
149+
}
167150
}
168151
}
169-
170-
signing {
171-
useInMemoryPgpKeys(System.getenv('MAVEN_GPG_PRIVATE_KEY'), '')
172-
sign publishing.publications.mavenJava
173-
}
174-
175-
tasks.withType(Sign) {
176-
onlyIf { System.getenv('MAVEN_GPG_PRIVATE_KEY') != null }
177-
}

client/src/main/java/com/rstmdb/client/model/StringOrArrayDeserializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/**
1414
* Custom deserializer that handles a field which can be either a single string
15-
* or an array of strings on the wire. Always deserializes to List<String>.
15+
* or an array of strings on the wire. Always deserializes to {@code List<String>}.
1616
*/
1717
public class StringOrArrayDeserializer extends JsonDeserializer<List<String>> {
1818

settings.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/9.3.1/userguide/multi_project_builds.html in the Gradle documentation.
66
*/
77

8+
pluginManagement {
9+
plugins {
10+
id 'com.vanniktech.maven.publish' version '0.36.0'
11+
}
12+
}
13+
814
plugins {
915
// Apply the foojay-resolver plugin to allow automatic download of JDKs
1016
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'

0 commit comments

Comments
 (0)