From da0a064bfa74ff0e1e93602e765e95f00fa32f9b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 21 Aug 2025 15:09:43 +0800 Subject: [PATCH 1/2] add maven release workflow --- .github/workflows/maven-release.yml | 63 +++++++++++++++++++++++++++++ pom.xml | 44 ++++++++++++-------- 2 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/maven-release.yml diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml new file mode 100644 index 000000000000..3b1fa80b323e --- /dev/null +++ b/.github/workflows/maven-release.yml @@ -0,0 +1,63 @@ +name: Make release + +on: + pull_request: + push: + branches: + - master +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: 'zulu' + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build + run: ./mvnw clean install -DskipTests=true + #run: ./mvnw clean install + + publish-OSSRH: + runs-on: ubuntu-latest + name: Publish to Maven Central + needs: build + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - id: install-secret-key + name: Install gpg secret key + run: | + cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import + gpg --list-secret-keys --keyid-format LONG + + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: 'zulu' + server-id: central + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + + - name: Publish package + run: ./mvnw -DskipTests=true --batch-mode -P release -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy + env: + MAVEN_USERNAME: ${{ secrets.OSS_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSS_PASSWORD }} + diff --git a/pom.xml b/pom.xml index bc514c7ca2a9..24c5991f81b7 100644 --- a/pom.xml +++ b/pom.xml @@ -60,16 +60,6 @@ github https://github.com/openapitools/openapi-generator/issues - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - Apache License 2.0 @@ -436,12 +426,32 @@ release + + + central + Central Repository OSSRH + https://central.sonatype.com/ + + + central + Central Repository OSSRG Snapshots + https://central.sonatype.com/repository/maven-snapshots/ + + true + + + org.apache.maven.plugins maven-gpg-plugin - 1.6 + + + --pinentry-mode + loopback + + sign-artifacts @@ -453,14 +463,14 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 + org.sonatype.central + central-publishing-maven-plugin + 0.8.0 true - ossrh - https://oss.sonatype.org/ - true + central + true + required From 3afe88e3692c54528db3d215cdb897d6da562930 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 21 Aug 2025 15:29:33 +0800 Subject: [PATCH 2/2] minor updates --- .github/workflows/maven-release.yml | 8 +++----- pom.xml | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml index 3b1fa80b323e..50c8c47a290f 100644 --- a/.github/workflows/maven-release.yml +++ b/.github/workflows/maven-release.yml @@ -1,7 +1,6 @@ -name: Make release +name: Release to Maven Central (snapshot, stable) on: - pull_request: push: branches: - master @@ -28,7 +27,7 @@ jobs: run: ./mvnw clean install -DskipTests=true #run: ./mvnw clean install - publish-OSSRH: + publish: runs-on: ubuntu-latest name: Publish to Maven Central needs: build @@ -59,5 +58,4 @@ jobs: run: ./mvnw -DskipTests=true --batch-mode -P release -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy env: MAVEN_USERNAME: ${{ secrets.OSS_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSS_PASSWORD }} - + MAVEN_PASSWORD: ${{ secrets.OSS_PASSWORD }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 24c5991f81b7..936737967c34 100644 --- a/pom.xml +++ b/pom.xml @@ -446,6 +446,7 @@ org.apache.maven.plugins maven-gpg-plugin + 1.6 --pinentry-mode