From 9247859bf58cfaa57c56d83ccb14f12b2245c648 Mon Sep 17 00:00:00 2001 From: Maciej Modzelewski Date: Mon, 21 Oct 2024 17:30:19 +0200 Subject: [PATCH] Add action for publishing sdk to maven central --- .github/workflows/publish.yml | 29 +++++++++++++++ java-sdk/build.gradle.kts | 67 ++++++++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4b84860 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish to Maven Central + +on: [ workflow_dispatch ] + +env: + JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_PASSWORD }} + JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_USERNAME }} + JRELEASER_GIT_ROOT_SEARCH: true + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version-file: '.java-version' + distribution: 'temurin' + cache: 'gradle' + - name: Java version + run: | + java --version + - run: ./gradlew clean + - run: ./gradlew publish + - run: ./gradlew jreleaserFullRelease diff --git a/java-sdk/build.gradle.kts b/java-sdk/build.gradle.kts index 474e392..5891e09 100644 --- a/java-sdk/build.gradle.kts +++ b/java-sdk/build.gradle.kts @@ -1,14 +1,21 @@ plugins { id("java-library") + id("maven-publish") + id("org.jreleaser") version ("1.14.0") } group = "rs.iggy" -version = "0.0.1-SNAPSHOT" +version = "0.1.0" repositories { mavenCentral() } +java { + withJavadocJar() + withSourcesJar() +} + dependencies { implementation("org.apache.httpcomponents.client5:httpclient5:5.2.1") implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2") @@ -29,3 +36,61 @@ dependencies { tasks.withType { useJUnitPlatform() } + +publishing { + publications { + create("maven") { + artifactId = "iggy-java-sdk" + + from(components["java"]) + + pom { + name = "Iggy Java Client SDK" + description = "Official Java client SDK for Iggy.rs message streaming" + url = "https://github.com/iggy-rs/iggy-java-client" + licenses { + license { + name = "MIT License" + url = "https://github.com/iggy-rs/iggy-java-client/blob/main/LICENSE" + } + } + developers { + developer { + id = "mmodzelewski" + name = "Maciej Modzelewski" + email = "maciej@modzelewski.dev" + } + } + scm { + url = "https://github.com/iggy-rs/iggy-java-client" + connection = "scm:git:git://github.com/iggy-rs/iggy-java-client.git" + developerConnection = "scm:git:git://github.com/iggy-rs/iggy-java-client.git" + } + } + } + } + + repositories { + maven { + url = uri(layout.buildDirectory.dir("staging-deploy")) + } + } +} + +jreleaser { + signing { + setActive("ALWAYS") + armored = true + } + deploy { + maven { + mavenCentral { + create("sonatype") { + setActive("ALWAYS") + url = "https://central.sonatype.com/api/v1/publisher" + stagingRepository("build/staging-deploy") + } + } + } + } +}