From 4d691105831ac81f8a4a56359cfc4a0dbf6a18a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Andreasik?= Date: Sat, 14 Jun 2025 17:33:12 +0200 Subject: [PATCH 1/2] ci(release): add Maven Central publishing workflow --- .github/workflows/ci.yml | 142 ++++++++++++++++++++++++++++----- README.md | 32 +++----- check-deployed-package/pom.xml | 3 +- pom.xml | 65 ++++++++++++++- 4 files changed, 194 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0f0506..b95a5b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -217,7 +217,7 @@ jobs: sarif_file: 'trivy-results.sarif' continue-on-error: true - release: + github-release: name: Release to GitHub Packages runs-on: ubuntu-latest needs: [build, security-scan] @@ -266,20 +266,117 @@ jobs: - name: Build and Deploy to GitHub Packages run: | mvn clean deploy -B --no-transfer-progress \ - -Prelease \ + -Pgithub-release \ -DperformRelease=true \ -DskipTests=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Download Build Artifacts - uses: actions/download-artifact@v4 + - name: Notify GitHub Release Success + run: | + echo "✅ Successfully deployed logdash:${{ steps.version.outputs.version }} to GitHub Packages" + echo "📦 Available at: https://github.com/logdash-io/java-sdk/packages" + + maven-central-release: + name: Release to Maven Central + runs-on: ubuntu-latest + needs: [build, security-scan] + timeout-minutes: 30 + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: 'temurin' + + - name: Import GPG key + run: | + echo "$GPG_PRIVATE_KEY" | base64 -d | gpg --batch --import --no-tty + gpg --list-secret-keys --keyid-format LONG + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + + - name: Configure Maven Settings for Central + uses: whelk-io/maven-settings-xml-action@v22 + with: + servers: | + [ + { + "id": "central", + "username": "${env.CENTRAL_TOKEN_USERNAME}", + "password": "${env.CENTRAL_TOKEN_PASSWORD}" + } + ] + + - name: Extract Version Info + id: version + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + # Validate version matches tag + if [[ "v$VERSION" != "${GITHUB_REF#refs/tags/}" ]]; then + echo "::error::Version mismatch: POM version ($VERSION) doesn't match tag (${GITHUB_REF#refs/tags/})" + exit 1 + fi + + - name: Build and Deploy to Maven Central + run: | + mvn clean deploy -B --no-transfer-progress \ + -Pmaven-central-release \ + -DskipTests=true + env: + CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }} + CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: Wait for Central Processing + run: | + echo "⏳ Waiting for Maven Central processing..." + sleep 60 + echo "✅ Maven Central processing should be complete" + + - name: Notify Maven Central Success + run: | + echo "✅ Successfully deployed logdash:${{ steps.version.outputs.version }} to Maven Central" + echo "📦 Will be available at: https://central.sonatype.com/artifact/io.logdash/logdash/${{ steps.version.outputs.version }}" + echo "🌐 Maven Central: https://search.maven.org/artifact/io.logdash/logdash/${{ steps.version.outputs.version }}" + + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: [github-release, maven-central-release] + timeout-minutes: 10 + if: startsWith(github.ref, 'refs/tags/v') + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 with: - pattern: build-artifacts-* - merge-multiple: true + java-version: ${{ env.JAVA_VERSION }} + distribution: 'temurin' - - name: Prepare Release Assets + - name: Extract Version Info + id: version run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Build Release Artifacts + run: | + mvn clean package -B --no-transfer-progress -DskipTests=true mkdir -p release-assets cp target/logdash-${{ steps.version.outputs.version }}.jar release-assets/ cp target/logdash-${{ steps.version.outputs.version }}-sources.jar release-assets/ @@ -299,7 +396,7 @@ jobs: generate_release_notes: true draft: false body: | - # 🚀 Logdash Java SDK + # 🚀 Logdash Java SDK ${{ steps.version.outputs.version }} Official Java SDK for [Logdash.io](https://logdash.io) – Zero-configuration observability for developers. @@ -314,7 +411,7 @@ jobs: ## 📦 Installation - **Maven** + **Maven Central** ```xml io.logdash @@ -328,9 +425,6 @@ jobs: implementation 'io.logdash:logdash:${{ steps.version.outputs.version }}' ``` - **Direct JAR Download:** - [Download from GitHub Releases](https://github.com/logdash-io/java-sdk/releases) - ## 🏁 Quick Start ```java @@ -360,23 +454,27 @@ jobs: _See below for full release notes and change log._ - - name: Notify Deployment Success - run: | - echo "✅ Successfully deployed logdash:${{ steps.version.outputs.version }} to GitHub Packages" - echo "📦 Available at: https://github.com/logdash-io/java-sdk/packages" - notification: name: Notification runs-on: ubuntu-latest - needs: [validate, test, build, security-scan] - if: always() && github.ref == 'refs/heads/main' + needs: [validate, test, build, security-scan, github-release, maven-central-release] + if: always() && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) steps: - name: Check Workflow Status run: | if [[ "${{ needs.validate.result }}" == "failure" || "${{ needs.test.result }}" == "failure" || "${{ needs.build.result }}" == "failure" ]]; then - echo "❌ Workflow failed on main branch" - echo "::error::Critical job failed on main branch" + echo "❌ Workflow failed" + echo "::error::Critical job failed" + elif [[ "${{ startsWith(github.ref, 'refs/tags/v') }}" == "true" ]]; then + if [[ "${{ needs.github-release.result }}" == "success" && "${{ needs.maven-central-release.result }}" == "success" ]]; then + echo "🎉 Release completed successfully!" + echo "📦 Available on GitHub Packages and Maven Central" + else + echo "⚠️ Release partially failed" + echo "GitHub Release: ${{ needs.github-release.result }}" + echo "Maven Central: ${{ needs.maven-central-release.result }}" + fi else - echo "✅ Workflow completed successfully" + echo "✅ Workflow completed successfully on main branch" fi diff --git a/README.md b/README.md index d4fa52b..bbed044 100644 --- a/README.md +++ b/README.md @@ -27,25 +27,13 @@ metrics without complex configurations. Just add the SDK and start monitoring yo ### Installation -**Option 1: Download from GitHub Releases (Recommended)** +**Maven Central** -1. Download the latest JAR from [GitHub Releases](https://github.com/logdash-io/java-sdk/releases) -2. Add to your project classpath - -**Option 2: GitHub Packages (Maven/Gradle)** - -Add GitHub Packages repository to your build configuration: +Add the dependency to your project: **Maven:** ```xml - - - github - https://maven.pkg.github.com/logdash-io/java-sdk - - - io.logdash logdash @@ -56,18 +44,20 @@ Add GitHub Packages repository to your build configuration: **Gradle:** ```gradle -repositories { - maven { - url = uri("https://maven.pkg.github.com/logdash-io/java-sdk") - } +dependencies { + implementation 'io.logdash:logdash:0.1.0' } +``` + +**Gradle (Kotlin DSL):** +```kotlin dependencies { - implementation 'io.logdash:logdash:0.1.0' + implementation("io.logdash:logdash:0.1.0") } ``` -**Option 3: Local Installation** +**Local Installation** ```bash # Clone and install locally @@ -86,8 +76,6 @@ Then use in your project: ``` -> **Note:** Maven Central publication is planned for future releases. For now, use GitHub Releases or GitHub Packages. - ### Basic Usage ```java diff --git a/check-deployed-package/pom.xml b/check-deployed-package/pom.xml index d595667..eb34697 100644 --- a/check-deployed-package/pom.xml +++ b/check-deployed-package/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 com.logdash check diff --git a/pom.xml b/pom.xml index 284f8d4..d74a277 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,8 @@ 3.5.0 3.1.4 3.8.1 + 3.2.7 + 0.7.0 @@ -481,9 +483,9 @@ - + - release + github-release performRelease @@ -505,6 +507,65 @@ + + + maven-central-release + + + central + Central Repository + https://central.sonatype.com/api/v1/publisher + + + central + Central Repository Snapshots + https://central.sonatype.com/api/v1/publisher + + + + + + + org.sonatype.central + central-publishing-maven-plugin + ${central-publishing-maven-plugin.version} + true + + central + true + published + required + + + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + sign-artifacts + + sign + + verify + + GPG_PASSPHRASE + + --pinentry-mode + loopback + --batch + --no-tty + + + + + + + + + quality From 6ce8229bece049545242f0ae7cbcda23a75e2c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Andreasik?= Date: Sat, 14 Jun 2025 18:25:59 +0200 Subject: [PATCH 2/2] refactor(check): update package to io.logdash --- check-deployed-package/Check.java | 2 +- check-deployed-package/pom.xml | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/check-deployed-package/Check.java b/check-deployed-package/Check.java index 3913667..4b2229b 100644 --- a/check-deployed-package/Check.java +++ b/check-deployed-package/Check.java @@ -1,4 +1,4 @@ -package com.logdash.check; +package io.logdash.check; import io.logdash.sdk.Logdash; diff --git a/check-deployed-package/pom.xml b/check-deployed-package/pom.xml index eb34697..c02fc1b 100644 --- a/check-deployed-package/pom.xml +++ b/check-deployed-package/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 - com.logdash + io.logdash check 1.0.0 @@ -49,10 +49,7 @@ exec-maven-plugin 3.1.0 - com.logdash.check.Check - - - + io.logdash.check.Check