-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (99 loc) · 4.06 KB
/
push-and-pull_request.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
name: Build on Push and Pull Request
on:
- push
- pull_request
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Supported versions as of https://en.wikipedia.org/wiki/Java_version_history
java-version:
- 8
- 11
- 16
name: Build with JDK ${{ matrix.java-version }}
steps:
- name: Cache Dependencies
uses: actions/cache@v3
with:
key: maven-dependencies
path: ~/.m2/repository
- name: Check out
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: ${{ matrix.java-version }}
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Clean, Build, Install
run: |
set -o errexit -o pipefail
mvn clean install --activate-profiles dirty,dirty-package --update-snapshots --batch-mode --show-version 2>&1 | tee mvnout.txt
set +o errexit +o pipefail
- id: version
name: Evaluate Version
shell: bash {0}
run: |
project_version=`mvn help:evaluate --quiet --define expression=project.version --define forceStdout`
echo "Version: ${project_version}"
snapshot_version=`echo "${project_version}" | grep --perl-regexp --regexp="-SNAPSHOT$"`
if [ -n "${snapshot_version}" ]; then
echo "Identified as snapshot version"
echo "::set-output name=is-snapshot::true"
else
echo "Identified as release version"
echo "::set-output name=is-snapshot::false"
fi
- name: Test, Verify, Deploy
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.java-version == 8 && steps.version.outputs.is-snapshot == 'true' }}
run: |
set -o errexit -o pipefail
mvn deploy site --batch-mode --show-version 2>&1 | tee --append mvnout.txt
set +o errexit +o pipefail
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Test, Verify
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' || matrix.java-version != 8 || steps.version.outputs.is-snapshot != 'true' }}
run: |
set -o errexit -o pipefail
mvn verify site --define gpg.skip=true --batch-mode --show-version 2>&1 | tee --append mvnout.txt
set +o errexit +o pipefail
- name: Check Output
shell: bash {0}
run: |
chmod +x ./target/mvn-suppressions-parent.sh
mvnout=`cat mvnout.txt | grep --perl-regexp "(?i)\\[(ERR|WARN)" | ./target/mvn-suppressions-parent.sh "$JDK_VERSION"`
if [ -n "${mvnout}" ]; then
echo "[ERROR] The Maven output contains the following unknown warnings and errors:" >&2
echo "${mvnout}" >&2
false
else
echo "[INFO] No unknown warnings and errors found."
echo "${mvnout}" >&2
fi
env:
JDK_VERSION: ${{ matrix.java-version }}
- name: Prepare Site
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.java-version == 8 && steps.version.outputs.is-snapshot == 'true' }}
run: |
if [ -f ./target/site/index.html ]; then
rm ./target/site/index.html
fi
if [ -f ./CHANGELOG.md ]; then
cp ./CHANGELOG.md ./target/site/CHANGELOG.md
fi
if [ -f ./README.md ]; then
cp ./README.md ./target/site/README.md
fi
- name: Deploy Site
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.java-version == 8 && steps.version.outputs.is-snapshot == 'true' }}
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/site
enable_jekyll: true