-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (90 loc) · 3.65 KB
/
main.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: K2hash Java CI
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
# Trigger the workflow on release,
# but only when published
release:
types:
- published
jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11', '17', '21' ]
name: Java ${{ matrix.java }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Configure GPG Key
run: |
export GPG_TTY=$(tty)
echo -n "$GPG_SIGNING_KEY" | gpg --import --batch
env:
GPG_SIGNING_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
- name: List of keys on gpg
run: gpg --list-secret-keys --keyid-format LONG
- name: Set environments
run: |
echo "COMMON_MAVEN_OPTS=-Dmaven.compiler.failOnWarning=true -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.verbose=true -Dmaven.compiler.debuglevel=lines,vars,source" >> "$GITHUB_ENV"
- name: Install dependent packages
run: |
sudo apt-get install -y curl
curl -s https://packagecloud.io/install/repositories/antpickax/stable/script.deb.sh | sudo bash
sudo apt-get install -y k2hash-dev
- name: Run checkstyle
run: |
mvn ${{ env.COMMON_MAVEN_OPTS }} checkstyle:check
- name: Run package on version 8
if: "matrix.java == '8'"
run: |
mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=8 package
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Run package on version other than 8
if: "matrix.java != '8'"
run: |
mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.release=${{ matrix.java }} package
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Run javadoc
run: |
mvn ${{ env.COMMON_MAVEN_OPTS }} javadoc:javadoc
- name: Deploy the docs to github
if: "github.event_name == 'release' && matrix.java == '21'"
run: |
mvn ${{ env.COMMON_MAVEN_OPTS }} site
env:
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
- name: Set up Apache Maven Central
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
distribution: 'zulu'
java-version: ${{ matrix.java }}
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Publish to Apache Maven Central
if: "github.event_name == 'release' && matrix.java == '21'"
run: |
mvn ${{ env.COMMON_MAVEN_OPTS }} deploy -Prelease
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}