Better support Java 21 (code tweak and CI tests) #177
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
maven-verify: | |
name: "Build on Java ${{ matrix.java }}" | |
strategy: | |
matrix: | |
java: [8, 11, 17, 21] | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout sources" | |
uses: actions/checkout@v2 | |
- name: "Set up Java" | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: "temurin" | |
cache: 'maven' | |
- name: "Get Maven dependencies from cache" | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: "Build with Maven" | |
run: mvn --batch-mode verify | |
maven-deploy: | |
name: "Deploy snapshot to Sonatype OSSRH" | |
needs: maven-verify | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout sources" | |
uses: actions/checkout@v2 | |
- name: "Setup Java" | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: "temurin" | |
server-id: ossrh | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_PASSWORD | |
- name: "Get Maven dependencies from cache" | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: "Build and deploy to the Maven Central Repository" | |
run: mvn --batch-mode -DskipTests deploy | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} |