-
Notifications
You must be signed in to change notification settings - Fork 408
60 lines (56 loc) · 1.65 KB
/
maven-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: build
on:
push:
branches: [ main ]
pull_request:
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@v4
- 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@v4
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@v4
- 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@v4
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 }}