forked from CommandAPI/CommandAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (184 loc) · 10.7 KB
/
build.yml
File metadata and controls
227 lines (184 loc) · 10.7 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.
name: build
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
# os: [ubuntu-20.04, windows-2022]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
### Set up ###
- name: Checkout the CommandAPI repository
uses: actions/checkout@v3
- name: Setup JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven
- name: Checkout the BytecodeAnalyser repository
run: |
git clone https://github.com/CommandAPI/BytecodeAnalyser.git
cd BytecodeAnalyser
commitHash=$(git rev-parse HEAD)
echo "$commitHash"
- name: Compile BytecodeAnalyser using Gradle
run: |
cd BytecodeAnalyser
./gradlew jar
### Compilation ###
- name: Setup Paper NMS for all applicable versions
run: ./setupPaperNMS.sh
- name: Build the CommandAPI (Bukkit+Velocity) using maven
run: mvn clean install --batch-mode -P Platform.Bukkit,Platform.Velocity
### Check NMS_Common compiles against all compatible Minecraft versions
- name: Compile NMS_Common for 1.20 and 1.20.1
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_20_R1
- name: Compile NMS_Common for 1.20.2
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_20_R2
- name: Compile NMS_Common for 1.20.3 and 1.20.4
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_20_R3
- name: Compile NMS_Common for 1.20.5 and 1.20.6
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_20_R4
- name: Compile NMS_Common for 1.21 and 1.21.1
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_21_R1
- name: Compile NMS_Common for 1.21.2 and 1.21.3
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_21_R2
- name: Compile NMS_Common for 1.21.4
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_21_R3
- name: Compile NMS_Common for 1.21.5
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_21_R4
- name: Compile NMS_Common for 1.21.6 and 1.21.7 and 1.21.8
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_21_R5
- name: Compile NMS_Common for 1.21.9
run: mvn clean package -Dmaven.source.skip=true -Dmaven.javadoc.skip=true -pl :commandapi-bukkit-nms-common -am -P Platform.Bukkit,Spigot_1_21_R6
- name: Copy BytecodeAnalyser to nms-common target folder
run: mv BytecodeAnalyser/build/libs/BytecodeAnalyser*.jar commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-nms-common/target
- name: Run BytecodeAnalyser
run: |
cd commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-nms-common/target
chmod +x BytecodeAnalyser*.jar
java -jar BytecodeAnalyser*.jar
# - name: validate version-specific dependencies (nms-common)
# run: |
# nms_common_path="commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-nms-common/target/classes/dev/jorel/commandapi/nms/NMS_Common.class"
# if ! command -v javap &> /dev/null
# then
# echo "javap could not be found, skipping NMS Common validation check"
# exit
# else
# javapcommand=$(javap -v $nms_common_path | grep -E '#[0-9]+ = Class ' | cut -c 46- | sort | grep 'org/bukkit/craftbukkit')
# if [[ -n "$javapcommand" ]]; then
# echo "NMS Common has version-specific dependencies!"
# echo $javapcommand
# exit 1
# else
# echo "NMS Common has no version-specific dependencies :)"
# fi
# fi
### Bukkit tests across all NMS versions ###
# Dev note: Yes, I know I could put this under one run section, but it's a million times easier
# to see which version failed when it's got the version name and subsection in GitHub Actions
- name: Run Bukkit unit tests across all versions (1.20.5 - 1.20.6)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_5
- name: Run Bukkit unit tests across all versions (Mojang Mapped 1.20.5 - 1.20.6)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_5_Mojang
- name: Run Bukkit unit tests across all versions (1.20.3 - 1.20.4)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_3
- name: Run Bukkit unit tests across all versions (1.20.2)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_2
- name: Run Bukkit unit tests across all versions (1.20 - 1.20.1)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20
- name: Run Bukkit unit tests across all versions (Mojang Mapped 1.20 - 1.20.1)
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-test-tests -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20_Mojang
# It doesn't matter which version the Kotlin DSL uses. It should be version independent
- name: Run Bukkit Kotlin DSL unit tests
continue-on-error: true
run: mvn clean package -pl :commandapi-bukkit-kotlin-test -P Platform.Bukkit -Dmaven.javadoc.skip=true -P Minecraft_1_20
### Upload .jar artifacts ###
- name: Upload CommandAPI (Spigot) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: CommandAPI (Spigot plugin)
path: |
commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/*sources.jar
!commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/*javadoc.jar
- name: Upload CommandAPI (Paper) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: CommandAPI (Paper plugin)
path: |
commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/*sources.jar
!commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/*javadoc.jar
- name: Upload CommandAPI (Velocity) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: CommandAPI (Velocity plugin)
path: |
commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/target/*sources.jar
!commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/target/*javadoc.jar
### Examples ###
- name: Build CommandAPI example plugins in examples/ folder
run: cd ./examples; ./build.sh;
### Save PR information for 'SonarAnalyze'
- name: Save PR number to file
if: github.event_name == 'pull_request' && ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.java_version }} == '21'
run: echo ${{ github.event.number }} > PR_NUMBER.txt
- name: Archive PR number
if: github.event_name == 'pull_request' && ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.java_version }} == '21'
uses: actions/upload-artifact@v4
with:
name: PR_NUMBER
path: PR_NUMBER.txt
snapshot-deploy:
needs: build # Only run if "build" succeeds
runs-on: ubuntu-latest
if: github.repository == 'CommandAPI/CommandAPI' && github.ref == 'refs/heads/dev/dev'
steps:
- name: Checkout the CommandAPI repository
uses: actions/checkout@v3
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
server-id: central # Needs to match the id in the main pom.xml file
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
java-version: 21
cache: maven
- name: Deploy snapshot version of the CommandAPI (Bukkit+Velocity) to the Sonatype snapshot repository
run: |
if mvn help:evaluate -Dexpression=project.version -q -DforceStdout | grep -E -q '\-SNAPSHOT$'; then
echo "SNAPSHOT version detected: $(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
mvn deploy --batch-mode -P Platform.Bukkit,Platform.Velocity -DskipTests=true
else
echo "Version is not a SNAPSHOT version, not deploying to Sonatype Snapshot repo"
fi
env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_PASSWORD }}