From 3e8278d7c4c995616cbbd0a5eaeb8815011f97c2 Mon Sep 17 00:00:00 2001 From: Rogerio Angeliski Date: Fri, 25 Oct 2024 22:14:53 -0300 Subject: [PATCH] Enable auto publish (#302) * config pom to release * add workflow * add branch just for test * add gpg config to profile * change nexus server * improve workflow * change commit user * skip ci from release commit * update checkout --- .github/workflows/ci.yml | 8 +++- .github/workflows/pr-validation.yml | 6 ++- .github/workflows/sonatype-publish.yml | 47 ++++++++++++++++++ pom.xml | 66 ++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/sonatype-publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e2a49ed..6c41c331 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,16 @@ name: Java CI -on: [push] +on: + push: + branches: + - master + env: MAVEN_OPTS: -Dmaven.artifact.threads=256 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn jobs: build: runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + steps: - uses: actions/checkout@v4 - name: Setup Java JDK diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 7988e7a0..67167059 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -1,5 +1,9 @@ name: Pull Request -on: [pull_request] +on: + pull_request: + branches: + - master + env: MAVEN_OPTS: -Dmaven.artifact.threads=256 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn jobs: diff --git a/.github/workflows/sonatype-publish.yml b/.github/workflows/sonatype-publish.yml new file mode 100644 index 00000000..1b8397fb --- /dev/null +++ b/.github/workflows/sonatype-publish.yml @@ -0,0 +1,47 @@ +name: Maven Release + +on: + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: 'Cache Maven packages' + uses: actions/cache@v4 + with: + path: ~/.m2 + key: 'cache' + restore-keys: 'cache' + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 11 + + - name: 'Build with Maven' + run: mvn -B install --file pom.xml + + - name: Release + uses: qcastel/github-actions-maven-release@master + env: + JAVA_HOME: /usr/lib/jvm/java-11-openjdk/ + with: + git-release-bot-name: "angeliski" + git-release-bot-email: "angeliski@hotmail.com" + + maven-args: "-DskipTests -PsonatypeDeploy" + maven-servers: ${{ secrets.MVN_REPO_SERVERS }} + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + gpg-enabled: true + gpg-key-id: ${{ secrets.GPG_KEY_ID }} + gpg-key: ${{ secrets.GPG_KEY }} + gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} + + - name: 'Remove Snapshots Before Caching' + run: find ~/.m2 -name '*SNAPSHOT' | xargs rm -Rf \ No newline at end of file diff --git a/pom.xml b/pom.xml index a2c84251..96d0f0f2 100644 --- a/pom.xml +++ b/pom.xml @@ -202,6 +202,14 @@ + + maven-release-plugin + 3.1.1 + + [ci skip] + @{project.version} + + @@ -435,6 +443,64 @@ + + + sonatypeDeploy + + ${env.GPG_PASSPHRASE} + ${env.GPG_KEY_ID} + ${env.GPG_PASSPHRASE} + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://oss.sonatype.org/ + + false + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + +