Skip to content

Build

Build #97

Workflow file for this run

name: Build
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
- 'hotfix/v*.*.*'
schedule:
- cron: '0 5 * * 1'
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17', '21' ]
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
server-id: central
server-username: SONATYPE_USERNAME
server-password: SONATYPE_TOKEN
gpg-private-key: ${{ secrets.MICHELINBOT_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Lint
run: mvn spotless:check
- name: Build
run: mvn clean package
- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@v5
with:
report_paths: '**/target/surefire-reports/TEST-*.xml'
- name: Grype source code
if: matrix.java == '17'
id: grype_source_code
uses: anchore/scan-action@v6
with:
path: .
fail-build: true
severity-cutoff: high
only-fixed: true
- name: Upload Grype source code report
if: always() && steps.grype_source_code.outputs.sarif != ''
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.grype_source_code.outputs.sarif }}
category: 'source-code'
- name: Sonar
if: matrix.java == '17' && github.event.pull_request.head.repo.fork == false
run: mvn verify sonar:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Metadata
if: matrix.java == '17' && github.ref == 'refs/heads/main'
id: metadata
run: echo current_version=$(echo $(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)) >> $GITHUB_OUTPUT
- name: Deploy
if: matrix.java == '17' && github.ref == 'refs/heads/main' && endsWith(steps.metadata.outputs.current_version, '-SNAPSHOT')
run: mvn -B deploy -DskipTests -Psign
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MICHELINBOT_GPG_PASSPHRASE }}