Skip to content

Commit 9164094

Browse files
chore(ci): consolidate maven workflows into .github/workflows/maven-ci.yml and remove duplicates
Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com>
1 parent 4066f99 commit 9164094

5 files changed

Lines changed: 89 additions & 137 deletions

File tree

.github/workflows/maven-ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Maven CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch: {}
13+
14+
env:
15+
MAVEN_OPTS: -Xmx2g
16+
17+
jobs:
18+
build:
19+
name: Build and Test (matrix)
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
java: [8, 11, 17]
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up JDK ${{ matrix.java }}
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: temurin
34+
java-version: ${{ matrix.java }}
35+
cache: maven
36+
37+
- name: Cache local Maven repo
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.m2/repository
41+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
42+
restore-keys: |
43+
${{ runner.os }}-maven-
44+
45+
- name: Build and run tests
46+
run: mvn -B -U -e -DskipTests=false verify
47+
48+
publish:
49+
name: Publish (snapshots/releases)
50+
runs-on: ubuntu-latest
51+
needs: build
52+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Set up JDK 11
60+
uses: actions/setup-java@v4
61+
with:
62+
distribution: temurin
63+
java-version: 11
64+
cache: maven
65+
66+
- name: Configure GPG key (for releases)
67+
if: startsWith(github.ref, 'refs/tags/')
68+
run: |
69+
echo "$GPG_PRIVATE_KEY" | base64 --decode > private.key
70+
gpg --batch --import private.key
71+
env:
72+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY_BASE64 }}
73+
74+
- name: Deploy release to Maven Central
75+
if: startsWith(github.ref, 'refs/tags/')
76+
env:
77+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
78+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
79+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
80+
run: |
81+
mvn -B -P release -DskipTests deploy -Dgpg.passphrase="$GPG_PASSPHRASE"
82+
83+
- name: Deploy snapshot to OSSRH (on main branch)
84+
if: github.ref == 'refs/heads/main'
85+
env:
86+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
87+
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
88+
run: |
89+
mvn -B -DskipTests deploy -P snapshot

.github/workflows/maven-publish-snapshot.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/maven-publish.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/maven_pull_request.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/maven_push.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)