-
-
Notifications
You must be signed in to change notification settings - Fork 5
182 lines (162 loc) · 7.89 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# 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: Build with Maven
on:
push:
branches: [ main ]
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
# Compile the project
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure maven's settings.xml (mirrors, deployment credentials)
uses: whelk-io/maven-settings-xml-action@v22
with:
mirrors: >
[
{
"id": "Sonatype-Nexus-Snapshots-mirror",
"name": "Sonatype-Nexus-Snapshots-Repository [Mirror]",
"url": "https://repo.sprax2013.de/repository/sonatype-nexus-snapshots/",
"mirrorOf": "sonatype-nexus-snapshots"
},
{
"id": "Central-mirror",
"name": "Central-Repository [Mirror]",
"url": "https://repo.sprax2013.de/repository/central/",
"mirrorOf": "central"
},
{
"id": "SpigotMC-Snapshots-mirror",
"name": "SpigotMC-Snapshots-Repository [Mirror]",
"url": "https://repo.sprax2013.de/repository/SpigotMC-Snapshots/",
"mirrorOf": "SpigotMC,SpigotMC-repo,spigotmc,spigotmc-repo,spigot-repo,spigotmc-snapshots"
},
{
"id": "SpigotMC-Releases-mirror",
"name": "SpigotMC-Releases-Repository [Mirror]",
"url": "https://repo.sprax2013.de/repository/SpigotMC-Releases/",
"mirrorOf": "spigotmc-releases"
},
{
"id": "Minecraft-Libraries-mirror",
"name": "Minecraft-Libraries-Repository [Mirror]",
"url": "https://repo.sprax2013.de/repository/Minecraft-Libraries/",
"mirrorOf": "minecraft-libraries"
}
]
# Use Java 8 to compile old Spigot version
- uses: actions/setup-java@v4
with:
java-version: 8
distribution: temurin
overwrite-settings: false
cache: maven
- name: Compile Spigot versions (1.8 – 1.16.5)
uses: SpraxDev/Action-SpigotMC@v5
with:
versions: 1.8, 1.8.3, 1.8.8, 1.9.2, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13, 1.13.2, 1.14.4, 1.15.2, 1.16.1, 1.16.3, 1.16.5
sftpCacheHost: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST }}
sftpCachePort: ${{ vars.SPIGOT_BUILDTOOLS_SFTP_PORT }}
sftpCacheUser: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_USER }}
sftpCachePrivateKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_PRIVATE_KEY }}
sftpCacheExpectedHostKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST_KEY }}
# Use Java 16 for Spigot 1.17
- uses: actions/setup-java@v4
with:
java-version: 16
distribution: temurin
overwrite-settings: false
- name: Compile Spigot versions (1.17)
uses: SpraxDev/Action-SpigotMC@v5
with:
versions: '1.17'
sftpCacheHost: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST }}
sftpCachePort: ${{ vars.SPIGOT_BUILDTOOLS_SFTP_PORT }}
sftpCacheUser: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_USER }}
sftpCachePrivateKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_PRIVATE_KEY }}
sftpCacheExpectedHostKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST_KEY }}
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
overwrite-settings: false
- name: Compile Spigot versions (1.18.1 – 1.20.4)
uses: SpraxDev/Action-SpigotMC@v5
with:
versions: 1.18.1, 1.18.2, 1.19, 1.19.2, 1.19.3, 1.19.4, 1.20.1, 1.20.2, 1.20.4
remapped: true
sftpCacheHost: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST }}
sftpCachePort: ${{ vars.SPIGOT_BUILDTOOLS_SFTP_PORT }}
sftpCacheUser: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_USER }}
sftpCachePrivateKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_PRIVATE_KEY }}
sftpCacheExpectedHostKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST_KEY }}
# Use Java 21 for everything else
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
overwrite-settings: false
- name: Compile Spigot versions (1.20.6 – 1.21)
uses: SpraxDev/Action-SpigotMC@v5
with:
versions: 1.20.6, 1.21
remapped: true
sftpCacheHost: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST }}
sftpCachePort: ${{ vars.SPIGOT_BUILDTOOLS_SFTP_PORT }}
sftpCacheUser: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_USER }}
sftpCachePrivateKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_PRIVATE_KEY }}
sftpCacheExpectedHostKey: ${{ secrets.SPIGOT_BUILDTOOLS_SFTP_HOST_KEY }}
# Compile the project using maven
- name: Build with Maven
run: 'mvn -B -Duser.name="GitHub Runner on $GITHUB_REPOSITORY (id=$GITHUB_RUN_ID)" clean package'
# Upload the .jar file
- name: 'Upload Build Artifact: BetterChairs.jar'
uses: actions/upload-artifact@v4
with:
name: BetterChairs
path: ./modules/betterchairs-plugin/target/BetterChairs*.jar
# Run static code analysis
- name: 'SonarCloud.io (static code analysis)'
if: ${{ env.SONAR_TOKEN != null }}
run: 'mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Check if the versions inside `pom.xml`, CHANGELOG.md and `./docs/version.txt`
# match and that everything has been edited correctly when pushing a new release version
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract version from the pom.xml and compare to docs/version.txt
id: version_diff # Outputs 'same' or 'diff'
run: mkdir -p docs && echo $(grep --max-count=1 '<version>' pom.xml | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }') >> docs/version_new.txt && diff -q --ignore-space-change --strip-trailing-cr --ignore-blank-lines docs/version.txt docs/version_new.txt 2>&1 && echo "result=same" >> $GITHUB_OUTPUT || echo "result=diff" >> $GITHUB_OUTPUT
- name: Check if extracted version matches docs/version.txt
if: ${{ steps.version_diff.outputs.result != 'same' }}
uses: unsplash/comment-on-pr@master
with:
msg: "Versions in `pom.xml` and `docs/version.txt` are not the same! Please use the same version in both files."
check_for_duplicate_msg: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if version from docs/version.txt is inside CHANGELOG.md
id: inside_changelog # Outputs 'yes' or 'no'
run: verTxt=$(cat docs/version.txt) && grep -q "## Version ${verTxt}" CHANGELOG.md && echo "result=yes" >> $GITHUB_OUTPUT || echo "result=no" >> $GITHUB_OUTPUT
- name: Check if extracted version matches docs/version.txt
if: ${{ steps.inside_changelog.outputs.result != 'yes' }}
uses: unsplash/comment-on-pr@master
with:
msg: "`CHANGELOG.md` is missing changes for version in `docs/version.txt`!"
check_for_duplicate_msg: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail Action when versions (from above) are not the same
if: ${{ steps.version_diff.outputs.result != 'same' }}
run: echo "The versions inside pom.xml and docs/version.txt are not the same!" && exit -1
- name: Fail Action when docs/version.txt not inside CHANGELOG.md
if: ${{ steps.inside_changelog.outputs.result != 'yes' }}
run: echo "CHANGELOG.md is missing changes for version in docs/version.txt!" && exit -1