From 9e3ce1a53610a4913363878146b89de1dc337232 Mon Sep 17 00:00:00 2001 From: Travis Wyatt Date: Tue, 21 May 2024 13:09:36 -0700 Subject: [PATCH] Use `setup-gradle` GitHub action (#155) --- .github/workflows/ci.yml | 31 +++-------------------------- .github/workflows/documentation.yml | 6 ++++++ .github/workflows/publish.yml | 25 ++++++----------------- .github/workflows/signing.yml | 24 ++++++++++++++++++++++ 4 files changed, 39 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/signing.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ca1133..d020186 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,35 +11,10 @@ jobs: with: distribution: 'temurin' java-version: '11' - - - uses: actions/cache@v4 + - uses: gradle/actions/setup-gradle@v3 with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-build- - ${{ runner.os }}- + validate-wrappers: true - run: ./gradlew assemble - run: ./gradlew check - - - run: | - set -o xtrace - if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then - ./gradlew \ - -PVERSION_NAME="unspecified" \ - -PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}" \ - -PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}" \ - publishToMavenLocal - else - ./gradlew \ - -PVERSION_NAME="unspecified-SNAPSHOT" \ - publishToMavenLocal - fi - if: ${{ github.repository_owner == 'JuulLabs' }} - - - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties + - run: ./gradlew -PRELEASE_SIGNING_ENABLED=false publishToMavenLocal diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index f756573..02dbcda 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -9,6 +9,12 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + - uses: gradle/actions/setup-gradle@v3 + - run: ./gradlew dokkaHtmlMultiModule - uses: JamesIves/github-pages-deploy-action@v4 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e905c76..3fd39e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,27 +13,14 @@ jobs: with: distribution: 'temurin' java-version: '11' - - - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-publish-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-publish- - ${{ runner.os }}- + - uses: gradle/actions/setup-gradle@v3 - run: ./gradlew check - run: >- ./gradlew - -PVERSION_NAME="${GITHUB_REF/refs\/tags\//}" - -PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}" - -PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}" - -PmavenCentralUsername="${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}" - -PmavenCentralPassword="${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}" + -PVERSION_NAME='${{ github.ref_name }}' + -PsigningInMemoryKey='${{ secrets.SIGNING_KEY }}' + -PsigningInMemoryKeyPassword='${{ secrets.SIGNING_PASSWORD }}' + -PmavenCentralUsername='${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}' + -PmavenCentralPassword='${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}' publish - - - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties diff --git a/.github/workflows/signing.yml b/.github/workflows/signing.yml new file mode 100644 index 0000000..eed1d83 --- /dev/null +++ b/.github/workflows/signing.yml @@ -0,0 +1,24 @@ +name: Validate Maven Signing +on: + push: + branches: + - main + +jobs: + signing: + if: github.repository_owner == 'JuulLabs' + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - uses: gradle/actions/setup-gradle@v3 + + - name: publishToMavenLocal + run: > + ./gradlew + -PsigningInMemoryKey='${{ secrets.SIGNING_KEY }}' + -PsigningInMemoryKeyPassword='${{ secrets.SIGNING_PASSWORD }}' + publishToMavenLocal