name: Master Build and Publish
# For master push: Builds and publishes the development version to maven
on:
  push:
    branches:
      - master
permissions: # For test summary bot
  checks: write
jobs:
  buildAndPublish:
    runs-on: ubuntu-latest
    env:
      MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }}
      MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
      MAVEN_CENTRAL_USER_NEW: ${{ secrets.MAVEN_CENTRAL_USER_NEW }}
      MAVEN_CENTRAL_PASSWORD_NEW: ${{ secrets.MAVEN_CENTRAL_PASSWORD_NEW }}
      MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }}

    steps:
      - uses: actions/checkout@v5
      - uses: gradle/actions/wrapper-validation@v5
      - name: Set up JDK 21
        uses: actions/setup-java@v5
        with:
          java-version: '21'
          distribution: 'corretto'
      - name: build test and publish
        run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace
      - name: Publish Test Results
        uses: EnricoMi/publish-unit-test-result-action@v2.20.0
        if: always()
        with:
          files: |
            **/build/test-results/test/TEST-*.xml
            **/build/test-results/testWithJava11/TEST-*.xml
            **/build/test-results/testWithJava17/TEST-*.xml
