Skip to content

Commit

Permalink
Simplify GitHub workflows when using Maven commands
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Feb 6, 2025
1 parent 5d2891b commit 69940d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/java-ea-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- develop
workflow_dispatch:

env:
MAVEN_ARGS: "-B -ntp"

jobs:
build-and-test-job:
strategy:
Expand Down Expand Up @@ -33,8 +36,8 @@ jobs:

- name: Build and (headless) test with Maven (Linux)
if: ${{ runner.os == 'Linux' }}
run: xvfb-run mvn -U -B -ntp verify
run: xvfb-run mvn -U verify

- name: Build and (headless) test with Maven (Windows and macOS)
if: ${{ runner.os != 'Linux' }}
run: mvn -U -B -ntp verify
run: mvn -U verify
17 changes: 10 additions & 7 deletions .github/workflows/java8-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Java8+ with Maven

on: [ push, pull_request ]

env:
MAVEN_ARGS: "-B -ntp"

jobs:
build-and-test-job:
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/tags/v')
Expand Down Expand Up @@ -31,17 +34,17 @@ jobs:
- name: Pre-download dependencies with Maven
uses: nick-fields/retry@v3
with:
command: mvn -U -B -ntp dependency:go-offline
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 -U -B -ntp verify
run: xvfb-run mvn -U verify

- name: Build and (headless) test with Maven (Windows and macOS)
if: ${{ runner.os != 'Linux' }}
run: mvn -U -B -ntp verify
run: mvn -U verify

auto-merge-job:
needs: build-and-test-job
Expand Down Expand Up @@ -90,15 +93,15 @@ jobs:
cache: 'maven'

- name: Deploy snapshot with Maven if settings defined
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests -s ci.settings.xml -P base-deploy,snapshot-deploy,!non-deployable-modules
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 -B -ntp install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser -Djreleaser.dry.run
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 }}
Expand Down Expand Up @@ -140,7 +143,7 @@ jobs:
cache: 'maven'

- name: Deploy with Maven if settings defined
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests -s ci.settings.xml -P base-deploy,release-deploy,!non-deployable-modules
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 }}
Expand All @@ -150,7 +153,7 @@ jobs:
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 -B -ntp install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser
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 }}
Expand Down

0 comments on commit 69940d4

Please sign in to comment.