Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored to reuse GitHub Actions workflows #478

Merged
merged 1 commit into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
107 changes: 6 additions & 101 deletions .github/workflows/build.yml
Expand Up @@ -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
51 changes: 51 additions & 0 deletions .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
58 changes: 58 additions & 0 deletions .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 }}
101 changes: 6 additions & 95 deletions .github/workflows/release.yml
Expand Up @@ -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
Expand Down
48 changes: 2 additions & 46 deletions .github/workflows/verify.yml
Expand Up @@ -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() }}
Expand Down