Introduce jreleaser to make the release (#19)

This commit is contained in:
Leonid Stashevsky 2024-12-17 15:55:27 +01:00 • committed by GitHub
commit 98410df7af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 33 deletions

View file

@ -28,8 +28,8 @@ jobs:
java-version: '21' java-version: '21'
distribution: 'temurin' distribution: 'temurin'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: OSSRH_USERNAME server-username: JRELEASER_MAVENCENTRAL_USERNAME
server-password: OSSRH_TOKEN server-password: JRELEASER_MAVENCENTRAL_PASSWORD
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
@ -38,10 +38,10 @@ jobs:
run: ./gradlew build run: ./gradlew build
- name: Publish to OSSRH repository - name: Publish to OSSRH repository
run: ./gradlew publish run: ./gradlew jreleaserPublish
env: env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
SIGNING_KEY_PRIVATE: ${{ secrets.SIGNING_KEY_PRIVATE }} JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}

View file

@ -1,21 +1,15 @@
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
import org.jreleaser.model.Active
plugins { plugins {
alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization) alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.dokka) alias(libs.plugins.dokka)
alias(libs.plugins.jreleaser)
`maven-publish` `maven-publish`
} }
if (project.getSensitiveProperty("SIGNING_KEY_PRIVATE") != null) {
apply(plugin = "signing")
}
tasks.withType<PublishToMavenRepository>().configureEach {
dependsOn(tasks.withType<Sign>())
}
group = "io.modelcontextprotocol" group = "io.modelcontextprotocol"
version = "0.1.0" version = "0.1.0"
@ -39,28 +33,12 @@ dependencies {
testImplementation(libs.kotlinx.coroutines.debug) testImplementation(libs.kotlinx.coroutines.debug)
} }
val ossrhUsername = System.getenv("OSSRH_USERNAME")
?: project.findProperty("OSSRH_USERNAME") as String?
val ossrhPassword = System.getenv("OSSRH_TOKEN")
?: project.findProperty("OSSRH_TOKEN") as String?
val sources = tasks.create<Jar>("sourcesJar") { val sources = tasks.create<Jar>("sourcesJar") {
from(sourceSets["main"].allSource) from(sourceSets["main"].allSource)
archiveClassifier.set("sources") archiveClassifier.set("sources")
} }
publishing { publishing {
repositories {
maven(url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
name = "ossrh"
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
publications { publications {
create<MavenPublication>("maven") { create<MavenPublication>("maven") {
groupId = project.group.toString() groupId = project.group.toString()
@ -79,6 +57,28 @@ publishing {
artifact(javadocJar) artifact(javadocJar)
artifact(sources) artifact(sources)
} }
repositories {
maven(url = layout.buildDirectory.dir("staging-deploy"))
}
}
jreleaser {
signing {
active.set(Active.ALWAYS)
armored = true
}
deploy {
maven {
mavenCentral {
val ossrh by creating {
active.set(Active.ALWAYS)
url.set("https://central.sonatype.com/api/v1/publisher")
stagingRepository("target/staging-deploy")
}
}
}
}
} }
fun MavenPom.configureMavenCentralMetadata() { fun MavenPom.configureMavenCentralMetadata() {

View file

@ -9,6 +9,7 @@ coroutines = "1.9.0"
ktor = "3.0.2" ktor = "3.0.2"
mockk = "1.13.13" mockk = "1.13.13"
logging = "7.0.0" logging = "7.0.0"
jreleaser = "1.15.0"
[libraries] [libraries]
# Kotlinx libraries # Kotlinx libraries
@ -35,3 +36,4 @@ mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser"}