Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
Comment thread
Copilot marked this conversation as resolved.

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
- uses: gradle/actions/setup-gradle@v5
- name: Check that the tag matches the project version
run: |
version=$(./gradlew -q properties --property version | sed -n 's/^version: //p')
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "Tag $GITHUB_REF_NAME does not match project version $version" >&2
exit 1
fi
- name: Build and test
run: ./gradlew build
- name: Publish with JReleaser
run: ./gradlew publishAllPublicationsToStagingRepository jreleaserFullRelease
Comment thread
Copilot marked this conversation as resolved.
env:
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE }}
JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86 changes: 61 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import org.jreleaser.model.Active

plugins {
id("java-library")
id("checkstyle")
alias(libs.plugins.maven.publish)
id("maven-publish")
alias(libs.plugins.jreleaser)
}

group = "org.komamitsu"
Expand All @@ -12,6 +15,8 @@ java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()
}

repositories {
Expand All @@ -31,7 +36,7 @@ dependencies {
// PackageVersion.java carries the coordinates and version Jackson reports via Versioned.
// Generate it from the Gradle project so it cannot drift from the published POM.
val packageDir = "org/komamitsu/jackson/dataformat/msgpack"
val generatePackageVersion by tasks.registering {
val generatePackageVersion = tasks.register("generatePackageVersion") {
val outputDir = layout.buildDirectory.dir("generated/sources/packageVersion/java/main")
val projectVersion = project.version.toString()
val projectGroup = project.group.toString()
Expand Down Expand Up @@ -128,32 +133,63 @@ checkstyle {
maxWarnings = 0
}

mavenPublishing {
publishToMavenCentral()
signAllPublications()

pom {
name = project.name
description = project.description
url = "https://github.com/komamitsu/jackson-dataformat-msgpack"
licenses {
license {
name = "Apache-2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
// Publications are staged locally; JReleaser signs them and uploads them to the Central Portal.
val stagingDir = layout.buildDirectory.dir("staging-deploy")

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])

pom {
name = project.name
description = project.description
url = "https://github.com/komamitsu/jackson-dataformat-msgpack"
licenses {
license {
name = "Apache-2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "komamitsu"
name = "Mitsunori Komatsu"
email = "komamitsu@gmail.com"
url = "https://github.com/komamitsu"
}
}
scm {
url = "https://github.com/komamitsu/jackson-dataformat-msgpack"
connection = "scm:git:git://github.com/komamitsu/jackson-dataformat-msgpack.git"
developerConnection = "scm:git:ssh://git@github.com/komamitsu/jackson-dataformat-msgpack.git"
}
}
}
developers {
developer {
id = "komamitsu"
name = "Mitsunori Komatsu"
email = "komamitsu@gmail.com"
url = "https://github.com/komamitsu"
}
}
repositories {
maven {
name = "staging"
url = uri(stagingDir)
}
scm {
url = "https://github.com/komamitsu/jackson-dataformat-msgpack"
connection = "scm:git:git://github.com/komamitsu/jackson-dataformat-msgpack.git"
developerConnection = "scm:git:ssh://git@github.com/komamitsu/jackson-dataformat-msgpack.git"
}
}

jreleaser {
signing {
pgp {
active = Active.ALWAYS
armored = true
}
}
deploy {
maven {
mavenCentral.create("sonatype") {
active = Active.ALWAYS
url = "https://central.sonatype.com/api/v1/publisher"
applyMavenCentralRules = true
stagingRepository(stagingDir.get().asFile.path)
}
}
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ hamcrest = "3.0"
commons-math3 = "3.6.1"
jmh = "1.37"
jmh-plugin = "0.7.3"
maven-publish-plugin = "0.34.0"
jreleaser = "1.26.0"

[libraries]
jackson-databind = { module = "tools.jackson.core:jackson-databind", version.ref = "jackson" }
Expand All @@ -18,4 +18,4 @@ commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "co

[plugins]
jmh = { id = "me.champeau.jmh", version.ref = "jmh-plugin" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish-plugin" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
Loading