From 2f2bf88f1f16ee8bd767e8b55be4a2ce4b934a6c Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Fri, 29 Nov 2024 11:20:14 +0400 Subject: [PATCH 1/2] Publish snapshot and test results are skipped when workflow is run by dependabot --- .github/workflows/compaund-java-sonatype-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compaund-java-sonatype-push.yml b/.github/workflows/compaund-java-sonatype-push.yml index 14ef1bb5..33a38a74 100644 --- a/.github/workflows/compaund-java-sonatype-push.yml +++ b/.github/workflows/compaund-java-sonatype-push.yml @@ -69,7 +69,7 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.sonatypeSigningKey }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.sonatypeSigningPassword }} - name: Dev Build with Gradle - if: ${{ !inputs.closeAndRelease }} + if: !inputs.closeAndRelease && github.actor != 'dependabot[bot]' run: ./gradlew -p ${{ inputs.projectPath }} --info clean build -Prelease_version=${{ format('{0}-SNAPSHOT', inputs.version) }} publish env: ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.sonatypeUsername }} @@ -78,7 +78,7 @@ jobs: ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.sonatypeSigningPassword }} - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() + if: always() && github.actor != 'dependabot[bot]' with: files: | ${{ inputs.projectPath }}/build/test-results/**/*.xml From 27ddb3473c7c2f220e72f999e5452ecf9afb6183 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Fri, 29 Nov 2024 14:25:52 +0400 Subject: [PATCH 2/2] Corrected after review --- .../workflows/compaund-java-sonatype-push.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compaund-java-sonatype-push.yml b/.github/workflows/compaund-java-sonatype-push.yml index 33a38a74..52d9dc3b 100644 --- a/.github/workflows/compaund-java-sonatype-push.yml +++ b/.github/workflows/compaund-java-sonatype-push.yml @@ -60,17 +60,23 @@ jobs: uses: gradle/actions/setup-gradle@v4 with: gradle-version: wrapper - - name: Release Build with Gradle + - name: Build release with Gradle if: ${{ inputs.closeAndRelease }} - run: ./gradlew -p ${{ inputs.projectPath }} --info clean build -Prelease_version=${{ inputs.version }} publish closeAndReleaseSonatypeStagingRepository + run: ./gradlew -p ${{ inputs.projectPath }} --info clean build -Prelease_version=${{ inputs.version }} + - name: Publish release with Gradle + if: ${{ inputs.closeAndRelease }} + run: ./gradlew -p ${{ inputs.projectPath }} --info -Prelease_version=${{ inputs.version }} publish closeAndReleaseSonatypeStagingRepository env: ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.sonatypeUsername }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.sonatypePassword }} ORG_GRADLE_PROJECT_signingKey: ${{ secrets.sonatypeSigningKey }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.sonatypeSigningPassword }} - - name: Dev Build with Gradle - if: !inputs.closeAndRelease && github.actor != 'dependabot[bot]' - run: ./gradlew -p ${{ inputs.projectPath }} --info clean build -Prelease_version=${{ format('{0}-SNAPSHOT', inputs.version) }} publish + - name: Build snapshot with Gradle + if: ${{ !inputs.closeAndRelease }} + run: ./gradlew -p ${{ inputs.projectPath }} --info clean build -Prelease_version=${{ format('{0}-SNAPSHOT', inputs.version) }} + - name: Publish snapshot with Gradle + if: ${{ !inputs.closeAndRelease && github.actor != 'dependabot[bot]' }} + run: ./gradlew -p ${{ inputs.projectPath }} --info -Prelease_version=${{ format('{0}-SNAPSHOT', inputs.version) }} publish env: ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.sonatypeUsername }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.sonatypePassword }}