Skip to content

Commit 98410df

Browse files
authored
Introduce jreleaser to make the release (#19)
1 parent 74dbce4 commit 98410df

File tree

3 files changed

+35
-33
lines changed

3 files changed

+35
-33
lines changed

.github/workflows/gradle-publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
java-version: '21'
2929
distribution: 'temurin'
3030
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
31-
server-username: OSSRH_USERNAME
32-
server-password: OSSRH_TOKEN
31+
server-username: JRELEASER_MAVENCENTRAL_USERNAME
32+
server-password: JRELEASER_MAVENCENTRAL_PASSWORD
3333

3434
- name: Setup Gradle
3535
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
@@ -38,10 +38,10 @@ jobs:
3838
run: ./gradlew build
3939

4040
- name: Publish to OSSRH repository
41-
run: ./gradlew publish
41+
run: ./gradlew jreleaserPublish
4242
env:
43-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
44-
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
45-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
46-
SIGNING_KEY_PRIVATE: ${{ secrets.SIGNING_KEY_PRIVATE }}
47-
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
43+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
44+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
45+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
46+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
47+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}

build.gradle.kts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
22
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
3+
import org.jreleaser.model.Active
34

45
plugins {
56
alias(libs.plugins.kotlin.jvm)
67
alias(libs.plugins.kotlin.serialization)
78
alias(libs.plugins.dokka)
9+
alias(libs.plugins.jreleaser)
810
`maven-publish`
911
}
1012

11-
if (project.getSensitiveProperty("SIGNING_KEY_PRIVATE") != null) {
12-
apply(plugin = "signing")
13-
}
14-
15-
tasks.withType<PublishToMavenRepository>().configureEach {
16-
dependsOn(tasks.withType<Sign>())
17-
}
18-
1913
group = "io.modelcontextprotocol"
2014
version = "0.1.0"
2115

@@ -39,28 +33,12 @@ dependencies {
3933
testImplementation(libs.kotlinx.coroutines.debug)
4034
}
4135

42-
val ossrhUsername = System.getenv("OSSRH_USERNAME")
43-
?: project.findProperty("OSSRH_USERNAME") as String?
44-
45-
val ossrhPassword = System.getenv("OSSRH_TOKEN")
46-
?: project.findProperty("OSSRH_TOKEN") as String?
47-
4836
val sources = tasks.create<Jar>("sourcesJar") {
4937
from(sourceSets["main"].allSource)
5038
archiveClassifier.set("sources")
5139
}
5240

5341
publishing {
54-
repositories {
55-
maven(url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
56-
name = "ossrh"
57-
credentials {
58-
username = ossrhUsername
59-
password = ossrhPassword
60-
}
61-
}
62-
}
63-
6442
publications {
6543
create<MavenPublication>("maven") {
6644
groupId = project.group.toString()
@@ -79,6 +57,28 @@ publishing {
7957
artifact(javadocJar)
8058
artifact(sources)
8159
}
60+
61+
repositories {
62+
maven(url = layout.buildDirectory.dir("staging-deploy"))
63+
}
64+
}
65+
66+
jreleaser {
67+
signing {
68+
active.set(Active.ALWAYS)
69+
armored = true
70+
}
71+
deploy {
72+
maven {
73+
mavenCentral {
74+
val ossrh by creating {
75+
active.set(Active.ALWAYS)
76+
url.set("https://central.sonatype.com/api/v1/publisher")
77+
stagingRepository("target/staging-deploy")
78+
}
79+
}
80+
}
81+
}
8282
}
8383

8484
fun MavenPom.configureMavenCentralMetadata() {

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ coroutines = "1.9.0"
99
ktor = "3.0.2"
1010
mockk = "1.13.13"
1111
logging = "7.0.0"
12+
jreleaser = "1.15.0"
1213

1314
[libraries]
1415
# Kotlinx libraries
@@ -34,4 +35,5 @@ mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
3435
[plugins]
3536
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
3637
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
37-
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
38+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
39+
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser"}

0 commit comments

Comments
 (0)