-
Notifications
You must be signed in to change notification settings - Fork 5
113 lines (108 loc) · 4.33 KB
/
maven.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# 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: [ main ]
pull_request:
branches: [ main ]
release:
types: [ created ]
env:
JAVA_REFERENCE_VERSION: 11
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ] # TODO add: windows-latest, macOS-latest
java: [ 11, 16-ea ]
fail-fast: false
max-parallel: 6
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
environment: configure coverage
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- id: version
uses: ./.github/actions/get-version
with:
versionPattern: '${{ env.JAVA_REFERENCE_VERSION }}.[0-9]*.[0-9]*'
- uses: actions/cache@v1 # cache maven packages to speed up build
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Set up JDK ${{matrix.java}}
uses: actions/[email protected]
with:
java-version: ${{matrix.java}}
- name: Test with Maven
run: mvn -Dgpg.skip=true --no-transfer-progress --batch-mode -Drevision=${REVISION} -Dsha1=${SHA1} -Dchangelist=${CHANGELIST} package
env:
REVISION: ${{ steps.version.outputs.revision }}
SHA1: ${{ steps.version.outputs.sha1 }}
CHANGELIST: ${{ steps.version.outputs.changelist }}
- name: coverage report - send to Codecov
if: matrix.java == env.JAVA_REFERENCE_VERSION
uses: codecov/[email protected]
- name: coverage report - send to Codacy
if: matrix.java == env.JAVA_REFERENCE_VERSION
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
publish:
name: Deploy to github packages and Sonatype OSSRH
needs: test
runs-on: ubuntu-latest
environment: deploy
steps:
- uses: actions/checkout@v2
- id: version
uses: ./.github/actions/get-version
with:
versionPattern: '${{ env.JAVA_REFERENCE_VERSION }}.[0-9]*.[0-9]*'
- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Cache the Maven packages to speed up build
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Set up JDK ${{ env.JAVA_REFERENCE_VERSION }}
uses: actions/[email protected]
with:
java-version: ${{ env.JAVA_REFERENCE_VERSION }}
gpg-private-key: ${{ secrets.GPG_KEY }}
gpg-passphrase: GPG_PASS
- name: Deploy to Github Packages
run: if [ -z "$CHANGELIST" ]; then mvn -DskipTests --no-transfer-progress --batch-mode -Drevision=${REVISION} -Dsha1=${SHA1} -Dchangelist=${CHANGELIST} -Drelease=github deploy; fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASS: ${{ secrets.GPG_PASSPHRASE }}
REVISION: ${{ steps.version.outputs.revision }}
SHA1: ${{ steps.version.outputs.sha1 }}
CHANGELIST: ${{ steps.version.outputs.changelist }}
- name: Set up JDK to publish to OSSRH
uses: actions/[email protected]
with:
java-version: ${{ env.JAVA_REFERENCE_VERSION }}
server-id: ossrh
server-username: SONATYPE_USER
server-password: SONATYPE_PASS
# gpg-private-key: ${{ secrets.GPG_KEY }} # gpg key was already added in the first java-setup phase, will fail the cleanup if added again
gpg-passphrase: GPG_PASS
- name: Deploy to Maven Central
run: mvn -DskipTests --no-transfer-progress --batch-mode -Drevision=${REVISION} -Dsha1=${SHA1} -Dchangelist=${CHANGELIST} -Drelease=ossrh deploy
env:
GPG_PASS: ${{ secrets.GPG_PASSPHRASE }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASS: ${{ secrets.SONATYPE_PASS }}
REVISION: ${{ steps.version.outputs.revision }}
SHA1: ${{ steps.version.outputs.sha1 }}
CHANGELIST: ${{ steps.version.outputs.changelist }}
...