Upgrade to java 21 #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '[ Start ] Build Project (Java/Maven)' | |
on: | |
workflow_dispatch: | |
inputs: | |
release_build: | |
description: 'toggles an release-build, by default false' | |
type: boolean | |
default: false | |
required: false | |
build_version: | |
description: 'The version to build and deploy' | |
type: string | |
required: true | |
default: '0-SNAPSHOT' | |
workflow_call: | |
inputs: | |
release_build: | |
description: 'toggles an release-build, by default false' | |
type: boolean | |
default: false | |
required: false | |
build_version: | |
description: 'The version to build and deploy' | |
type: string | |
required: false | |
default: '0-SNAPSHOT' | |
outputs: | |
build_artifact_id: | |
description: 'The id of the uploaded build artifacts.' | |
value: ${{ jobs.Build.outputs.build_artifacts_id}} | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
BUILD_VERSION: ${{ inputs.build_version != '' && inputs.build_version || '0-SNAPSHOT' }} | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
outputs: | |
build_artifacts_id: ${{ steps.BuildArtifactUpload.outputs.artifact-id }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
cache: 'maven' | |
cache-dependency-path: '**/pom.xml' | |
server-id: 'github' | |
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} | |
gpg-passphrase: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} | |
- name: Set version | |
if: ${{ inputs.release_build }} | |
run: ./mvnw versions:set -DnewVersion=${{ env.BUILD_VERSION }} -DgenerateBackupPoms=false | |
- name: Build project, run unit and integration tests | |
id: Build | |
run: ./mvnw -T1C --batch-mode clean install | |
- name: Evaluate branch name where the scan results are added to in Sonarcloud | |
if: ${{inputs.actor != 'dependabot[bot]' }} | |
id: branch_to_scan | |
shell: bash | |
run: | | |
echo github.head_ref - pull request: ${{ github.head_ref }} | |
echo github.ref_name - push: ${{ github.ref_name }} | |
echo event: ${{ github.event_name }} | |
echo branch name to scan: ${{ github.head_ref || github.ref_name }} | |
echo name=${{ github.head_ref || github.ref_name }} >> $GITHUB_OUTPUT | |
- name: Javadoc and sign artifacts | |
if: ${{ inputs.release_build }} | |
run: ./mvnw -T1C --batch-mode package gpg:sign -Dgpg.signer=bc | |
env: | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} | |
MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }} | |
GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
- name: (Info) Display structure of files | |
run: tree | |
- name: Upload build artifacts | |
id: BuildArtifactUpload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts-${{ inputs.build_version }} | |
path: | | |
./**/target/*${{ inputs.build_version }}*.jar | |
./**/target/*${{ inputs.build_version }}*.zip | |
./**/target/*${{ inputs.build_version }}*.asc | |
./**/target/reports/ | |
retention-days: 10 |