-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (65 loc) · 2.2 KB
/
maven_build.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ master ]
paths:
- '**/src/**'
- '**/pom.xml'
pull_request:
branches: [ master ]
paths:
- '**/src/**'
- '**/pom.xml'
workflow_dispatch:
inputs:
tags:
description: 'Run reason'
required: true
default: 'Simple UI trigger'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 11, 17, 21 ]
outputs:
pom-version: ${{ steps.get-pom-version.outputs.pom-version }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'zulu'
- name: Build with Maven
run: mvn -B clean package --file pom.xml --no-transfer-progress
- name: Get POM version
id: get-pom-version
run: |
VERSION=$( mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml --no-transfer-progress )
echo "Found project version: $VERSION"
echo "pom-version=$VERSION" >> $GITHUB_OUTPUT
publish-snapshot:
needs: build
runs-on: ubuntu-latest
if: ${{ contains(needs.build.outputs.pom-version, 'SNAPSHOT') && github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v4
- name: Set up settings.xml for OSS
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'zulu'
server-id: oss.sonatype.org
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish SNAPSHOT version to OSS
run: mvn -B clean deploy --no-transfer-progress -DskipTests=true --file pom.xml
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASS }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}