diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 7f8c5eb8..523a656c 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -32,6 +32,14 @@ jobs: server-username: ${{ secrets.OSSRH_USERNAME }} server-password: ${{ secrets.OSSRH_PASSWORD }} + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Configure GPG Key run: | echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 8158ab2b..4c99b1bc 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -18,6 +18,15 @@ jobs: java-version: '8' distribution: 'temurin' cache: maven + + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Configure GPG Key run: | echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fa286e7..28615aa2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,8 @@ # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle +# maven deploy commands via via https://tech.clevertap.com/automate-releases-to-maven-central-via-github-actions/ + name: Release on: @@ -26,16 +28,34 @@ jobs: with: java-version: '8' distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee - with: - arguments: build - # The USERNAME and TOKEN need to correspond to the credentials environment variables used in - # the publishing section of your build.gradle - - name: Publish to Sonatype (Maven) - uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee - with: - arguments: publish -PossrhUsername=${{ secrets.OSSRH_USERNAME }} -PossrhPassword=${{ secrets.OSSRH_PASSWORD }} + cache: maven + server-id: ossrh + server-username: ${{ secrets.OSSRH_USERNAME }} + server-password: ${{ secrets.OSSRH_PASSWORD }} + + - name: Configure GPG Key + run: | + echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import env: - release: true - REPOSITORY_URL: https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + + - name: Build with Maven + run: mvn --batch-mode --update-snapshots verify + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + directory: lib/build + flags: unittests # optional + name: coverage # optional + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) + - name: Deploy + run: | + mvn -P gpg_verify \ + --no-transfer-progress \ + --batch-mode \ + --file pom.xml -s release/m2-settings.xml verify deploy + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} diff --git a/release/m2-settings.xml b/release/m2-settings.xml new file mode 100644 index 00000000..9b7a585a --- /dev/null +++ b/release/m2-settings.xml @@ -0,0 +1,9 @@ + + + + ossrh + ${env.OSSRH_USERNAME} + ${env.OSSRH_PASSWORD} + + +