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 and Test -> Compute coverage -> Release if requested | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "src/main/**.java" | |
- "src/test/**.java" | |
- ".github/workflows/**" | |
- "**.properties" | |
- "**.xml" | |
jobs: | |
build-and-test-with-Java-8-and-later: | |
name: Build -> Test (JVM ${{ matrix.java }}, ${{ matrix.os }}) | |
strategy: | |
fail-fast: true | |
max-parallel: 16 | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
java: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] | |
architecture: [x64] | |
exclude: | |
- os: macOS-latest | |
java: 13 | |
- os: macOS-latest | |
java: 14 | |
- os: ubuntu-latest | |
java: 10 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: 'zulu' | |
architecture: ${{ matrix.architecture }} | |
- name: Build and test | |
run: mvn -B clean test -Dproject_jdk_version=${{ matrix.java }} -DskipTests=false --file pom.xml -X -U | |
release: | |
name: Release if requested | |
needs: [build-and-test-with-Java-8-and-later] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && endsWith(github.event.head_commit.message, 'Releasing new version') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 21 | |
distribution: 'zulu' | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Publish to the Maven Central repository | |
run: | | |
export GPG_TTY=$(tty) | |
echo "${{ secrets.gpg_private_key }}" | gpg --batch --import | |
git config user.name "${{ github.event.head_commit.committer.name }}" | |
git config user.email "${{ github.event.head_commit.committer.email }}" | |
mvn -B release:prepare release:perform -Dproject_jdk_version=8 -DskipTests=true -Dgpg.passphrase=${{ secrets.gpg_passphrase }} -Dgpg.keyname=${{ secrets.gpg_key_id }} -Drepository.url=https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git | |
env: | |
MAVEN_USERNAME: ${{ secrets.nexus_username }} | |
MAVEN_PASSWORD: ${{ secrets.nexus_password }} |