Migrate workflows to Azul Zulu Builds of OpenJDK #6
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: Java with Maven | |
on: [ push, pull_request, workflow_dispatch ] | |
env: | |
MAVEN_ARGS: "-B -ntp" | |
jobs: | |
vars-job: | |
name: Compute variables | |
runs-on: ubuntu-latest | |
outputs: | |
java_min: '8' | |
java_max: '21' | |
origin: 'nbbrd/' | |
steps: | |
- run: echo | |
build-and-test-job: | |
needs: vars-job | |
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/tags/v') | |
strategy: | |
fail-fast: false | |
matrix: | |
java: [ '${{ needs.vars-job.outputs.java_min }}', '${{ needs.vars-job.outputs.java_max }}' ] | |
os: [ ubuntu-latest ] | |
name: JDK${{ matrix.java }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout and Setup Maven | |
uses: s4u/setup-maven-action@v1.18.0 | |
with: | |
checkout-submodules: true | |
checkout-fetch-depth: 0 | |
java-version: ${{ matrix.java }} | |
- name: Pre-download dependencies with Maven | |
uses: nick-fields/retry@v3 | |
with: | |
command: mvn -U dependency:go-offline | |
max_attempts: 3 | |
timeout_minutes: 5 | |
- name: Build and (headless) test with Maven (Linux) | |
if: ${{ runner.os == 'Linux' }} | |
run: xvfb-run mvn verify | |
- name: Build and (headless) test with Maven (Windows and macOS) | |
if: ${{ runner.os != 'Linux' }} | |
run: mvn verify | |
# - name: Ensure reproducible builds with Maven | |
# run: mvn -U clean verify artifact:compare -DskipTests | |
snapshot-job: | |
needs: [ vars-job, build-and-test-job ] | |
if: startsWith(github.repository, needs.vars-job.outputs.origin) && startsWith(github.ref, 'refs/heads/develop') | |
name: Snapshot on develop | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout and Setup Maven | |
uses: s4u/setup-maven-action@v1.18.0 | |
with: | |
checkout-submodules: true | |
checkout-fetch-depth: 0 | |
java-version: ${{ needs.vars-job.outputs.java_max }} | |
- name: Deploy snapshot with Maven if settings defined | |
run: test ! -f ci.settings.xml || mvn deploy -DskipTests -s ci.settings.xml -P base-deploy,snapshot-deploy,!non-deployable-modules | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
SIGN_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Dryrun release assets with Maven | |
run: mvn install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser -Djreleaser.dry.run | |
env: | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} | |
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }} | |
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Upload JReleaser output | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: assets-snapshot-log | |
path: | | |
out/jreleaser/trace.log | |
out/jreleaser/output.properties | |
release-job: | |
needs: [ vars-job, build-and-test-job ] | |
if: startsWith(github.repository, needs.vars-job.outputs.origin) && startsWith(github.ref, 'refs/tags/v') | |
name: Release on tag | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout and Setup Maven | |
uses: s4u/setup-maven-action@v1.18.0 | |
with: | |
checkout-submodules: true | |
checkout-fetch-depth: 0 | |
java-version: ${{ needs.vars-job.outputs.java_max }} | |
- name: Deploy with Maven if settings defined | |
run: test ! -f ci.settings.xml || mvn deploy -DskipTests -s ci.settings.xml -P base-deploy,release-deploy,!non-deployable-modules | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
SIGN_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
# Fix https://issues.sonatype.org/browse/OSSRH-66257 | |
MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" | |
- name: Release assets with Maven | |
run: mvn install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser | |
env: | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} | |
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }} | |
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Upload JReleaser output | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: assets-release-log | |
path: | | |
out/jreleaser/trace.log | |
out/jreleaser/output.properties | |
auto-merge-job: | |
needs: [ vars-job, build-and-test-job ] | |
if: startsWith(github.repository, needs.vars-job.outputs.origin) && github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' | |
permissions: | |
contents: write | |
pull-requests: write | |
name: Auto-merge on dependabot PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Merge PR | |
uses: nick-fields/retry@v3 | |
with: | |
command: gh pr merge --auto --rebase "$PR_URL" | |
max_attempts: 3 | |
timeout_minutes: 5 | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |