name: Build on: push: branches: - "main" paths-ignore: - '.gitattributes' - '.gitignore' - '.github/renovate.json5' - '.github/project.yaml' - 'docs/**' - 'README.md' pull_request: env: COMMON_MAVEN_OPTS: "-e -B --fae" jobs: build: runs-on: ubuntu-latest steps: - name: Checkout the code uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 21 uses: https://github.com/actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' - name: Generate cache keys id: cache-key run: | CURRENT_BRANCH="${{ github.head_ref || github.ref_name }}" CURRENT_MONTH=$(/bin/date -u "+%Y-%m") CURRENT_DAY=$(/bin/date -u "+%d") ROOT_CACHE_KEY="m2-cache-quarkus-commons" echo "m2-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT echo "m2-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT echo "m2-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT - name: Cache Maven Repository id: cache-maven uses: actions/cache@v4 with: path: ~/.m2/repository # The cache is per branch but in case we don't find a branch for a given branch, we will get a cache from another branch. key: ${{ steps.cache-key.outputs.m2-cache-key }} restore-keys: | ${{ steps.cache-key.outputs.m2-monthly-branch-cache-key }} ${{ steps.cache-key.outputs.m2-monthly-cache-key }} - name: Configure Maven CI/CD settings uses: https://github.com/s4u/maven-settings-action@v3.1.0 with: servers: | [{ "id": "phoenix-oss", "configuration": { "httpHeaders": { "property": { "name": "Authorization", "value": "token ${{ secrets.ORG_PACKAGE_WRITER_TOKEN }}" } } } }] - name: Make maven wrapper executable run: chmod +x mvnw - name: Download dependencies run: ./mvnw $COMMON_MAVEN_OPTS quarkus:go-offline - name: Build and run tests run: ./mvnw $COMMON_MAVEN_OPTS verify - name: Analyze with Sonar if: vars.SONAR_ENABLED == 'true' env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} run: ./mvnw $COMMON_MAVEN_OPTS org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=quarkus-commons -Dsonar.projectName='quarkus-commons' -Dsonar.coverage.jacoco.xmlReportPaths=../**/target/jacoco-report/jacoco.xml - name: Publish jars if: github.ref == 'refs/heads/main' run: ./mvnw $COMMON_MAVEN_OPTS deploy -Dmaven.test.skip=true -Dmaven.javadoc.skip=true