name: Compatibility Build

on:
  workflow_dispatch:
  schedule:
    - cron: '5 6 * * *'

jobs:
  integration:
    strategy:
      fail-fast: false
      matrix:
        version:
        - '3.1.12'
        - '3.2.12'
        - '3.3.13-SNAPSHOT'
        - '3.4.4'
        - '3.4.5-SNAPSHOT'
        - '3.5.0-M3'
        - '3.5.0-SNAPSHOT'
        jmolecules:
        - '2023.2.2'
        - '2023.3.1'
        - '2025.0.0-RC3'
    name: Build against Boot ${{ matrix.version }}
    runs-on: ubuntu-latest

    steps:

    - name: Check out sources
      uses: actions/checkout@v4

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

    - name: Build with Maven
      env:
        COMMERCIAL_USERNAME: ${{ secrets.COMMERCIAL_ARTIFACTORY_RO_USERNAME }}
        COMMERCIAL_PASSWORD: ${{ secrets.COMMERCIAL_ARTIFACTORY_RO_PASSWORD }}
        DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
      run: |
        cd spring-modulith-examples
        ../mvnw -B versions:update-parent -DskipResolution=true -DparentVersion=${{ matrix.version }}
        ../mvnw -B clean verify -Pwith-preview-repos -Dspring-boot.version=${{ matrix.version }} -Djmolecules.version=${{ matrix.jmolecules }}
