diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4997037d..5a3661d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: branches: - master tags: - - "*" + - "v*" pull_request: branches: - master @@ -112,3 +112,98 @@ jobs: - name: Run classpath tests run: make PROFILES=${{ matrix.profile }} classpath + + publish: + name: Publish to Maven Central + needs: [test, classpath] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Set up Java + uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: '11' + cache: maven + mvn-server-credentials: | + central:CENTRAL_USERNAME:CENTRAL_TOKEN + github:GITHUB_ACTOR:GITHUB_TOKEN + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase-env-var: GPG_PASSPHRASE + + - name: Verify tag matches pom version + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/v} + POM_VERSION=$(./mvnw help:evaluate -N -Dexpression=project.version -q -DforceStdout | grep -v '\[') + echo "Tag version: $TAG_VERSION" + echo "POM version: $POM_VERSION" + if [[ "$POM_VERSION" != "$TAG_VERSION" ]]; then + echo "::error::Tag $TAG_VERSION does not match pom $POM_VERSION" + echo "::warning::Tag $TAG_VERSION does not match pom $POM_VERSION (expected if release:prepare not used with v prefix))" + exit 1 + fi + + - name: Publish to GitHub Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./mvnw --batch-mode -Pgithub -DskipTests deploy + + - name: Publish release to Maven Central + if: ${{ env.CENTRAL_USERNAME != '' }} + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: ./mvnw --batch-mode -Prelease -DskipTests deploy + + snapshot: + name: Publish snapshot + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + runs-on: ubuntu-24.04 + needs: [test, classpath] + permissions: + contents: read + packages: write + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Set up Java + uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: '11' + cache: maven + mvn-server-credentials: | + central:CENTRAL_USERNAME:CENTRAL_TOKEN + github:GITHUB_ACTOR:GITHUB_TOKEN + + - name: Publish snapshot to GitHub Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./mvnw --batch-mode -Pgithub -DskipTests deploy + + - name: Publish snapshot to Maven Central + if: ${{ env.CENTRAL_USERNAME != '' }} + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} + run: ./mvnw --batch-mode -DskipTests deploy diff --git a/.settings.xml b/.settings.xml index 85af33a3..2fd8efac 100644 --- a/.settings.xml +++ b/.settings.xml @@ -22,19 +22,14 @@ http://maven.apache.org/xsd/settings-1.0.0.xsd"> - sonatype - ${env.SONATYPE_USER} - ${env.SONATYPE_PASSWORD} + central + ${env.CENTRAL_USERNAME} + ${env.CENTRAL_TOKEN} - bintray - ${env.BINTRAY_USER} - ${env.BINTRAY_KEY} - - - jfrog-snapshots - ${env.BINTRAY_USER} - ${env.BINTRAY_KEY} + github + ${env.GITHUB_ACTOR} + ${env.GITHUB_TOKEN} github.com diff --git a/pom.xml b/pom.xml index 4c6e97c0..8256d557 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ 2.2.0.RELEASE - Hoxton.SR1 + Hoxton.SR12 4.3.0 2.2.0 1.3.1 @@ -114,6 +114,8 @@ 10.26.1 0.7.7 0.1.1 + 0.7.0 + 3.2.7 @@ -330,13 +332,9 @@ - - bintray - https://oss.jfrog.org/artifactory/oss-release-local - - jfrog-snapshots - https://oss.jfrog.org/artifactory/oss-snapshot-local + central + https://central.sonatype.com/repository/maven-snapshots/ @@ -404,7 +402,7 @@ false release true - @{project.version} + v@{project.version} @@ -499,8 +497,54 @@ + + + org.apache.maven.plugins + maven-gpg-plugin + ${version.maven-gpg-plugin} + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + org.sonatype.central + central-publishing-maven-plugin + ${version.org.sonatype.central-publishing-maven-plugin} + true + + central + true + published + + + + github + + + github + https://maven.pkg.github.com/opentracing-contrib/java-spring-cloud + + + github + https://maven.pkg.github.com/opentracing-contrib/java-spring-cloud + + +