diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3305c1b7..679bb10c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,109 +3,14 @@ on: push: branches: - master -env: - JAVA_TOOL_OPTIONS: >- - -XX:TieredStopAtLevel=1 - -XX:+UseParallelGC - -Dstyle.color=always - -Djansi.force=true jobs: build: - name: Maven build - runs-on: ubuntu-20.04 - strategy: - matrix: - maven-version: - - '3.3.9' - - '3.6.1' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} - - name: Build with Maven - run: .github/scripts/build.sh - env: - MAVEN_VERSION: ${{ matrix.maven-version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Code coverage report - if: matrix.maven-version == '3.6.1' - uses: codecov/codecov-action@v3.1.0 - - build-all: - if: ${{ always() }} - name: Build (matrix) - runs-on: ubuntu-20.04 - needs: build - steps: - - name: Check build matrix status - run: "[[ '${{ needs.build.result }}' == 'success' ]] || exit 1" + name: Build + uses: './.github/workflows/maven-build.yml' deploy: - name: Maven deploy - runs-on: ubuntu-20.04 - if: github.repository == 'gantsign/ktlint-maven-plugin' - needs: build-all - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }}-deploy - restore-keys: | - ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} - - name: Install GPG key - run: |- - gpg --batch --import-options import-show --import << EOF - ${{ secrets.GPG_KEY }} - EOF - - name: Deploy with Maven - run: .github/scripts/deploy.sh - env: - OSSRH_USER: ${{ secrets.OSSRH_USER }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Delete GPG secret key - if: ${{ always() }} - run: gpg --batch --yes --delete-secret-keys ${{ secrets.GPG_KEY_NAME }} || true - - name: Delete GPG public key - if: ${{ always() }} - run: gpg --batch --yes --delete-keys ${{ secrets.GPG_KEY_NAME }} + name: Deploy + needs: build + uses: './.github/workflows/maven-deploy.yml' + secrets: inherit diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml new file mode 100644 index 00000000..d6c83a34 --- /dev/null +++ b/.github/workflows/maven-build.yml @@ -0,0 +1,51 @@ +name: Maven build +on: + workflow_call: +env: + JAVA_TOOL_OPTIONS: >- + -XX:TieredStopAtLevel=1 + -XX:+UseParallelGC + -Dstyle.color=always + -Djansi.force=true + +jobs: + build: + name: Maven build + runs-on: ubuntu-20.04 + strategy: + matrix: + maven-version: + - '3.3.9' + - '3.6.1' + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: 'temurin' + # Since code changes to this project are infrequent, and most commits + # change the pom.xml, we cache by date interval rather than file hash. + - name: Calculate cache interval + run: | + leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" + echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" + id: cache-interval + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository + !~/.m2/repository/com/github/gantsign/maven + key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} + - name: Build with Maven + run: .github/scripts/build.sh + env: + MAVEN_VERSION: ${{ matrix.maven-version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Code coverage report + if: matrix.maven-version == '3.6.1' + uses: codecov/codecov-action@v3.1.0 diff --git a/.github/workflows/maven-deploy.yml b/.github/workflows/maven-deploy.yml new file mode 100644 index 00000000..558182ba --- /dev/null +++ b/.github/workflows/maven-deploy.yml @@ -0,0 +1,58 @@ +name: Maven deploy +on: + workflow_call: +env: + JAVA_TOOL_OPTIONS: >- + -XX:TieredStopAtLevel=1 + -XX:+UseParallelGC + -Dstyle.color=always + -Djansi.force=true + +jobs: + deploy: + name: Maven deploy + runs-on: ubuntu-20.04 + if: github.repository == 'gantsign/ktlint-maven-plugin' + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: 'temurin' + # Since code changes to this project are infrequent, and most commits + # change the pom.xml, we cache by date interval rather than file hash. + - name: Calculate cache interval + run: | + leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" + echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" + id: cache-interval + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository + !~/.m2/repository/com/github/gantsign/maven + key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }}-deploy + restore-keys: | + ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} + - name: Install GPG key + run: |- + gpg --batch --import-options import-show --import << EOF + ${{ secrets.GPG_KEY }} + EOF + - name: Deploy with Maven + run: .github/scripts/deploy.sh + env: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Delete GPG secret key + if: ${{ always() }} + run: gpg --batch --yes --delete-secret-keys ${{ secrets.GPG_KEY_NAME }} || true + - name: Delete GPG public key + if: ${{ always() }} + run: gpg --batch --yes --delete-keys ${{ secrets.GPG_KEY_NAME }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 372d7dbe..794f66e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,103 +12,14 @@ env: jobs: build: - name: Maven build - runs-on: ubuntu-20.04 - strategy: - matrix: - maven-version: - - '3.3.9' - - '3.6.1' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} - - name: Build with Maven - run: .github/scripts/build.sh - env: - MAVEN_VERSION: ${{ matrix.maven-version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Code coverage report - if: matrix.maven-version == '3.6.1' - uses: codecov/codecov-action@v3.1.0 - - build-all: - if: ${{ always() }} - name: Build (matrix) - runs-on: ubuntu-20.04 - needs: build - steps: - - name: Check build matrix status - run: "[[ '${{ needs.build.result }}' == 'success' ]] || exit 1" + name: Build + uses: './.github/workflows/maven-build.yml' deploy: - name: Maven deploy - runs-on: ubuntu-20.04 - if: github.repository == 'gantsign/ktlint-maven-plugin' - needs: build-all - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }}-deploy - restore-keys: | - ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} - - name: Install GPG key - run: |- - gpg --batch --import-options import-show --import << EOF - ${{ secrets.GPG_KEY }} - EOF - - name: Deploy with Maven - run: .github/scripts/deploy.sh - env: - OSSRH_USER: ${{ secrets.OSSRH_USER }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Delete GPG secret key - if: ${{ always() }} - run: gpg --batch --yes --delete-secret-keys ${{ secrets.GPG_KEY_NAME }} || true - - name: Delete GPG public key - if: ${{ always() }} - run: gpg --batch --yes --delete-keys ${{ secrets.GPG_KEY_NAME }} + name: Deploy + needs: build + uses: './.github/workflows/maven-deploy.yml' + secrets: inherit deploy-site: name: Maven deploy site diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index b2329571..0a188e4d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -3,54 +3,10 @@ name: Verify on: pull_request: -env: - JAVA_TOOL_OPTIONS: >- - -XX:TieredStopAtLevel=1 - -XX:+UseParallelGC - -Dstyle.color=always - -Djansi.force=true - jobs: build: - name: Maven build - runs-on: ubuntu-20.04 - strategy: - matrix: - maven-version: - - '3.3.9' - - '3.6.1' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} - - name: Build with Maven - run: .github/scripts/build.sh - env: - MAVEN_VERSION: ${{ matrix.maven-version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Code coverage report - if: matrix.maven-version == '3.6.1' - uses: codecov/codecov-action@v3.1.0 + name: Build + uses: './.github/workflows/maven-build.yml' build-all: if: ${{ always() }}