Skip to content

Commit

Permalink
Adding matrix-build
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Jun 21, 2024
1 parent 74b7a7d commit aa8faf1
Showing 1 changed file with 67 additions and 69 deletions.
136 changes: 67 additions & 69 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,90 +16,88 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
version: [17]
version: [ 17,21,22 ]

steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.version }}
distribution: 'temurin'
cache: maven
- name: Build with Maven, Java ${{ matrix.version }}
run: mvn --no-transfer-progress package -Dmaven.compiler.source=${{ matrix.version }} -Dmaven.compiler.target=${{ matrix.version }}

- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.version }}
distribution: 'temurin'
cache: maven
- name: Build with Maven, Java ${{ matrix.version }}
run: mvn --no-transfer-progress package -Dmaven.compiler.source=${{ matrix.version }} -Dmaven.compiler.target=${{ matrix.version }}
sonar-build:
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17 for Sonar-build
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- uses: radcortez/[email protected]
name: Retrieve project metadata from '.github/project.yml'
id: metadata
with:
github-token: ${{secrets.GITHUB_TOKEN}}
metadata-file-path: '.github/project.yml'
local-file: true
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify -Psonar -Dsonar.projectKey=${{steps.metadata.outputs.sonar-project-key}} sonar:sonar
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17 for Sonar-build
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- uses: radcortez/[email protected]
name: Retrieve project metadata from '.github/project.yml'
id: metadata
with:
github-token: ${{secrets.GITHUB_TOKEN}}
metadata-file-path: '.github/project.yml'
local-file: true

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify -Psonar -Dsonar.projectKey=${{steps.metadata.outputs.sonar-project-key}} sonar:sonar

deploy-snapshot:
needs: sonar-build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17 for snapshot release
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: sonatype-nexus-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
cache: maven
- uses: actions/checkout@v3
- name: Set up JDK 17 for snapshot release
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: sonatype-nexus-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
cache: maven

- name: Extract project version
id: project
run: echo ::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- name: Extract project version
id: project
run: echo ::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

- name: Deploy Snapshot with Maven, version ${{ steps.project.outputs.version }}
if: ${{endsWith(steps.project.outputs.version, '-SNAPSHOT')}}
# javadoc:aggregate -> Needs to be fixed: "Error: No source files for package de.cuioss.jsf.api.components.model"
# Actually we need to resolve it regarding https://maven.apache.org/plugins/maven-javadoc-plugin/examples/aggregate.html
run: |
mvn -B --no-transfer-progress -Prelease-snapshot install -Dmaven.javadoc.skip=true
mvn -B --no-transfer-progress -Prelease-snapshot deploy -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
env:
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Deploy Snapshot with Maven, version ${{ steps.project.outputs.version }}
if: ${{endsWith(steps.project.outputs.version, '-SNAPSHOT')}}
# javadoc:aggregate -> Needs to be fixed: "Error: No source files for package de.cuioss.jsf.api.components.model"
# Actually we need to resolve it regarding https://maven.apache.org/plugins/maven-javadoc-plugin/examples/aggregate.html
run: |
mvn -B --no-transfer-progress -Prelease-snapshot install -Dmaven.javadoc.skip=true
mvn -B --no-transfer-progress -Prelease-snapshot deploy -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
env:
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

0 comments on commit aa8faf1

Please sign in to comment.