diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml new file mode 100644 index 000000000000..50c8c47a290f --- /dev/null +++ b/.github/workflows/maven-release.yml @@ -0,0 +1,61 @@ +name: Release to Maven Central (snapshot, stable) + +on: + 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: + 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 }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index bc514c7ca2a9..936737967c34 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,33 @@ 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 +464,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