-
Notifications
You must be signed in to change notification settings - Fork 61
96 lines (96 loc) · 3.38 KB
/
ci.yaml
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
name: CI
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
jobs:
code-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache Maven
uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Check formatting
run: ./mvnw formatter:validate --no-transfer-progress
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8.x, 11.x, 17.x, 21.x]
steps:
- uses: actions/checkout@v1
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Cache Maven
uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit Tests
if: (github.ref != 'refs/heads/develop' && github.ref != 'refs/heads/main') || !startsWith(env.JAVA_HOME, '/opt/hostedtoolcache/jdk/8')
run: ./mvnw -V test --no-transfer-progress
- name: Unit Tests with Coverage
if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main') && startsWith(env.JAVA_HOME, '/opt/hostedtoolcache/jdk/8')
run: |
./mvnw -V jacoco:prepare-agent test jacoco:report --no-transfer-progress
- name: Deploy to sonatype-snapshots
if: github.ref == 'refs/heads/develop' && startsWith(env.JAVA_HOME, '/opt/hostedtoolcache/jdk/8')
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
set -e
cat > settings.xml <<EOF
<settings>
<servers>
<server>
<id>sonatype-snapshots</id>
<username>${SONATYPE_USERNAME}</username>
<password>${SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
EOF
CURRENT_VERSION=$(grep '<version>' pom.xml | head -n 1 | sed -e 's|<version>||g' -e 's|</version>||g' | xargs echo)
if [ "${CURRENT_VERSION}" = "$(echo ${CURRENT_VERSION} | grep "\-SNAPSHOT")" ];then
./mvnw -V deploy -s settings.xml -DskipTests=true -DserverId=sonatype-snapshots --no-transfer-progress
fi
- name: Deploy to sonatype-releases
if: github.ref == 'refs/heads/main' && startsWith(env.JAVA_HOME, '/opt/hostedtoolcache/jdk/8')
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
ENCRYPTION_PASSWORD: ${{ secrets.ENCRYPTION_PASSWORD }}
run: |
set -e
docker run \
--rm \
-e SONATYPE_USERNAME=${SONATYPE_USERNAME} \
-e SONATYPE_PASSWORD=${SONATYPE_PASSWORD} \
-e GPG_KEYNAME=${GPG_KEYNAME} \
-e GPG_PASSPHRASE=${GPG_PASSPHRASE} \
-e ENCRYPTION_PASSWORD=${ENCRYPTION_PASSWORD} \
-v ~/.m2:/root/.m2 \
-v "$PWD":/workspace \
-w /workspace \
making/deploy-sonatype