-
Notifications
You must be signed in to change notification settings - Fork 93
113 lines (109 loc) · 4.44 KB
/
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
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
---
name: Java CI
on: [push, pull_request]
env:
JAVA_REFERENCE_VERSION: 17
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
java: [17, 20]
fail-fast: false
max-parallel: 4
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
environment: coverage # open environment, no critical secrets
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 25
- name: Set version environment for version string
run: |
export REV=${GITHUB_REF#refs/*/}
echo "REVISION=${REV/\//-}" >> $GITHUB_ENV
if [[ "${GITHUB_REF#refs/tags/}" =~ ^${{ env.JAVA_REFERENCE_VERSION }}\.[0-9]*\.[0-9]*$ ]]; then
echo "CHANGELIST=" >> $GITHUB_ENV
else
echo "CHANGELIST=-SNAPSHOT" >> $GITHUB_ENV
fi
echo "github ref: ${GITHUB_REF}"
echo "setting env:"
cat ${GITHUB_ENV}
- name: Cache the Maven packages to speed up build
uses: actions/cache@v3
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/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Test with Maven
run: mvn -Dgpg.skip=true --no-transfer-progress --batch-mode -Drevision=${REVISION} -Dchangelist=${CHANGELIST} package
- name: CodeCov coverage Reporter
uses: codecov/codecov-action@v3
if: matrix.java == env.JAVA_REFERENCE_VERSION
- name: Codacy coverage Reporter
if: matrix.java == env.JAVA_REFERENCE_VERSION
continue-on-error: true # codacy coverage sometimes fails for external PRs, ignore since it is not our main coverage tracking
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
publish:
name: Deploy to github packages and Sonatype OSSRH
needs: test
runs-on: ubuntu-22.04
environment: deploy
steps:
- uses: actions/checkout@v3
- name: Set version environment for version string
run: |
export REV=${GITHUB_REF#refs/*/}
echo "REVISION=${REV/\//-}" >> $GITHUB_ENV
if [[ "${GITHUB_REF#refs/tags/}" =~ ^${{ env.JAVA_REFERENCE_VERSION }}\.[0-9]*\.[0-9]*$ ]]; then
echo "CHANGELIST=" >> $GITHUB_ENV
else
echo "CHANGELIST=-SNAPSHOT" >> $GITHUB_ENV
fi
echo "github ref: ${GITHUB_REF}"
echo "setting env:"
cat ${GITHUB_ENV}
- name: Cache the Maven packages to speed up build
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Set up the JDK ${{ env.JAVA_REFERENCE_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_REFERENCE_VERSION }}
distribution: 'adopt'
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} -Dchangelist=${CHANGELIST} -Drelease=github deploy; fi
continue-on-error: true # allows to restart the deployment step and not have the existing deployed github package prevent publishing to maven central
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASS: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up JDK to publish to OSSRH
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_REFERENCE_VERSION }}
distribution: 'adopt'
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} -Dchangelist=${CHANGELIST} -Drelease=ossrh deploy
env:
GPG_PASS: ${{ secrets.GPG_PASSPHRASE }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASS: ${{ secrets.SONATYPE_PASS }}
...