add reusable-jdk-os-matrix.yml
diff --git a/.github/workflows/reusable-jdk-os-matrix.yml b/.github/workflows/reusable-jdk-os-matrix.yml new file mode 100644 index 0000000..05be7b9 --- /dev/null +++ b/.github/workflows/reusable-jdk-os-matrix.yml
@@ -0,0 +1,89 @@ +name: Reusable JDK OS Matrix Logic + +on: + workflow_call: + inputs: + jdk_version: + required: true + type: string + os_type: + required: true + type: string + java_arch: + required: true + type: string + +env: + MAVEN_OPTS: -Xmx4g -Xms1g + MAVEN_ARGS: "-B -Dmaven.javadoc.skip=true -Dgpg.skip=true" + +jobs: + build: + name: Build (${{ inputs.os_type }}, JDK ${{ inputs.jdk_version }}, ${{ inputs.java_arch }}) + runs-on: ${{ inputs.os_type }} + steps: + - name: Checkout Source code + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Checkout Workflow Logic (workflows branch) + uses: actions/checkout@v4 + with: + ref: workflows + path: .github/workflow-logic + + - name: Install Matrix JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.jdk_version }} + distribution: 'temurin' + java-package: jdk + architecture: ${{ inputs.java_arch }} + cache: 'maven' + overwrite-settings: true + + - name: Verify Toolchain Configuration + shell: bash + run: | + if [ -f ~/.m2/toolchains.xml ]; then + cat ~/.m2/toolchains.xml + else + echo "toolchains.xml not found in ~/.m2/" + fi + + - name: Echo Java & Maven Version + run: mvn -version + + - name: Print Current Workflows + continue-on-error: true + run: | + echo "Checking for workflow files..." + echo "--- Reusable Workflow: ---" + cat .github/workflow-logic/.github/workflows/reusable-jdk-os-matrix.yml || echo "::warning::Could not find Reusable Workflow file." + echo "--- Caller Workflow: ---" + cat .github/workflows/auto-jdk-os-matrix.yml || echo "::warning::Could not find Caller Workflow file." + + - name: Test + run: mvn clean test + + - name: Install + run: mvn clean install "-DskipTests=true" "-Dmaven.clean.failOnError=false" + + - name: Add Result to Summary + if: always() + shell: bash + run: | + # Define the header + HEADER="| OS | Arch | JDK | Status |" + SEP="|----|------|-----|--------|" + + # Check if the header already exists in the summary file + if ! grep -q "$HEADER" "$GITHUB_STEP_SUMMARY"; then + echo "$HEADER" >> $GITHUB_STEP_SUMMARY + echo "$SEP" >> $GITHUB_STEP_SUMMARY + fi + + # Append the specific job row + echo "| ${{ inputs.os_type }} | ${{ inputs.java_arch }} | ${{ inputs.jdk_version }} | ${{ job.status == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY +