-
-
Notifications
You must be signed in to change notification settings - Fork 8
339 lines (333 loc) · 12.5 KB
/
check.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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: Check
run-name: Check ${{ inputs.version }}
permissions:
contents: write
on:
workflow_call:
inputs:
branch:
required: false
type: string
version:
required: true
type: string
push_changed:
default: true
required: false
type: boolean
publish:
default: true
required: false
type: boolean
secrets:
MAVEN_USER:
required: false
MAVEN_PASSWORD:
required: false
DISCORD_WEBHOOK_URL:
required: false
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
push_changed:
description: 'Push changed patches'
default: true
required: false
type: boolean
publish:
description: 'Publish'
default: true
required: false
type: boolean
jobs:
common:
runs-on: ubuntu-latest
outputs:
discord_embed: ${{ steps.discord_embed.outputs.discord_embed }}
jdk_version: ${{ steps.java_version.outputs.result }}
version_type: ${{ fromJson(steps.split_version.outputs.result).version_type }}
version_name: ${{ fromJson(steps.split_version.outputs.result).version_name }}
steps:
- uses: actions/github-script@v6
id: split_version
env:
VERSION: ${{ inputs.version }}
with:
script: |
const version = process.env.VERSION.split("/");
var returnValue = {version_name: version[version.length - 1], version_type: version[0]}
return returnValue;
- name: Create discord embed json
id: discord_embed
run: |
echo "discord_embed<<EOF" >> $GITHUB_OUTPUT
jq -n '[
{
"author": {
"name": $ENV.REPO_NAME,
"url": $ENV.REPO_URL,
"icon_url": "https://avatars.githubusercontent.com/u/138629134"
},
"url": $ENV.RUN_URL,
"fields": [
{
"name": "Build Branch",
"value": $ENV.BRANCH,
"inline": true
},
{
"name": "Minecraft Version",
"value": $ENV.MC_VERSION,
"inline": true
}
]
}
]' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
REPO_NAME: ${{ github.event.repository.name }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
BRANCH: ${{ inputs.branch || github.ref_name }}
MC_VERSION: ${{ fromJson(steps.split_version.outputs.result).version_name }}
- name: Create start discord embed json
id: discord_embed_start
run: |
echo "discord_embed<<EOF" >> $GITHUB_OUTPUT
echo "$DISCORD_EMBED" | jq 'map(. + {"title": "Started", "color": 3224808})' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
DISCORD_EMBED: ${{ steps.discord_embed.outputs.discord_embed }}
- name: Notify discord of start
if: ${{ inputs.publish }}
uses: Ilshidur/[email protected]
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_USERNAME: GitHub Actions
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
DISCORD_EMBEDS: ${{ steps.discord_embed_start.outputs.discord_embed }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || '' }}
- uses: actions/cache/restore@v3
name: Restore ${{ fromJson(steps.split_version.outputs.result).version_name }} cache
with:
path: |
build/versions/${{ fromJson(steps.split_version.outputs.result).version_name }}/**
versions/${{ inputs.version }}/build/download-task/**
key: version-${{ fromJson(steps.split_version.outputs.result).version_name }}-
- uses: actions/cache/restore@v3
name: Restore Assets cache
with:
path: build/assets/**
key: minecraft-assets-
- uses: actions/cache/restore@v3
name: Restore Libraries cache
with:
path: |
build/libraries/**
build/mc-libraries/**
key: minecraft-libraries-
- uses: actions/cache/restore@v3
name: Restore Version Manifest cache
with:
path: build/versions/version_manifest.json
key: minecraft-version-manifest-
- uses: actions/cache/restore@v3
name: Restore BuildSrc cache
with:
path: |
buildSrc/build/**
buildSrc/.gradle/**
key: buildsrc-build-
- uses: actions/cache/restore@v3
name: Restore Other cache
with:
path: |
build/download-task/**
.gradle/**
key: gradle-other-
- run: |
git config --global user.name github-actions
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Apply and Create patches
id: patches
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ fromJson(steps.split_version.outputs.result).version_name }}:projectApplyAll :${{ fromJson(steps.split_version.outputs.result).version_name }}:projectMakeAll -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }}
generate-job-summary: false
- name: Check if patches have changed
id: check_changes
if: ${{ inputs.push_changed }}
run: |
git add .
git diff-index --quiet HEAD || git commit -m "Update patches" && git push
- name: Make Zip
if: ${{ always() }}
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ fromJson(steps.split_version.outputs.result).version_name }}:makeZip -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }}
generate-job-summary: false
- name: Upload Zip as Artifact
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: neoform-${{ fromJson(steps.split_version.outputs.result).version_name }}
path: build/distributions/*.zip
- name: Get Java Version
id: java_version
uses: actions/github-script@v6
env:
VERSION: ${{ inputs.version }}
PATCHES_OUTCOME: ${{ steps.patches.outcome }}
with:
result-encoding: "string"
script: |
if (process.env.PATCHES_OUTCOME != 'success') {
return Number.MAX_SAFE_INTEGER;
}
const fs = require('fs');
const config = JSON.parse(fs.readFileSync('versions/' + process.env.VERSION + '/config.json', 'utf8'))
return config.java_target;
- uses: actions/cache/save@v3
name: Save ${{ fromJson(steps.split_version.outputs.result).version_name }} cache
with:
path: |
build/versions/${{ fromJson(steps.split_version.outputs.result).version_name }}/**
versions/${{ inputs.version }}/build/download-task/**
key: version-${{ fromJson(steps.split_version.outputs.result).version_name }}-${{ hashFiles(format('build/versions/{0}/**', fromJson(steps.split_version.outputs.result).version_name), format('versions/{0}/build/download-task/**', inputs.version))}}
- uses: actions/cache/save@v3
name: Save Assets cache
with:
path: build/assets/**
key: minecraft-assets-${{ hashFiles('build/assets/**' )}}
- uses: actions/cache/save@v3
name: Save Libraries cache
with:
path: |
build/libraries/**
build/mc-libraries/**
key: minecraft-libraries-${{ hashFiles('build/libraries/**')}}
- uses: actions/cache/save@v3
name: Save Version Manifest cache
with:
path: build/versions/version_manifest.json
key: minecraft-version-manifest-${{ hashFiles('build/versions/version_manifest.json')}}
- uses: actions/cache/save@v3
name: Save BuildSrc cache
with:
path: |
buildSrc/build/**
buildSrc/.gradle/**
key: buildsrc-build-${{ hashFiles('buildSrc/build/**', 'buildSrc/.gradle/**')}}
- uses: actions/cache/save@v3
name: Save Other cache
with:
path: |
build/download-task/**
.gradle/**
key: gradle-other-${{ hashFiles('build/download-task/**', '.gradle/**')}}
testjdks:
name: Test Jdks on side ${{ matrix.side }} using mappings ${{ matrix.mappings }} using java version ${{ matrix.jdk_version }}
runs-on: ubuntu-latest
needs: common
strategy:
fail-fast: false
matrix:
jdk_version: [17, 18, 19, 20, 21]
mappings: [HotSpot]
side: [Client, Joined, Server]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || '' }}
- uses: actions/cache/restore@v3
name: Restore ${{ needs.common.outputs.version_name }} cache
with:
path: |
build/versions/${{ needs.common.outputs.version_name }}/**
versions/${{ inputs.version }}/build/download-task/**
key: version-${{ needs.common.outputs.version_name }}-
- uses: actions/cache/restore@v3
name: Restore Assets cache
with:
path: build/assets/**
key: minecraft-assets-
- uses: actions/cache/restore@v3
name: Restore Libraries cache
with:
path: |
build/libraries/**
build/mc-libraries/**
key: minecraft-libraries-
- uses: actions/cache/restore@v3
name: Restore Version Manifest cache
with:
path: build/versions/version_manifest.json
key: minecraft-version-manifest-
- uses: actions/cache/restore@v3
name: Restore BuildSrc cache
with:
path: |
buildSrc/build/**
buildSrc/.gradle/**
key: buildsrc-build-
- uses: actions/cache/restore@v3
name: Restore Other cache
with:
path: |
build/download-task/**
.gradle/**
key: gradle-other-
- name: Test jdk
if: ${{ matrix.jdk_version >= needs.common.outputs.jdk_version}}
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ needs.common.outputs.version_name }}:testCompile${{ matrix.side }}${{ matrix.mappings }}${{ matrix.jdk_version }} :${{ needs.common.outputs.version_name }}:testDecompile${{ matrix.side }}${{ matrix.mappings }}${{ matrix.jdk_version }}Compare -Ptype=${{ needs.common.outputs.version_type }}
generate-job-summary: false
publish:
name: Publish to maven
runs-on: ubuntu-latest
needs: [common, testjdks]
outputs:
timestamp: ${{ env.GRADLE_TIMESTAMP }}
if: ${{ inputs.publish }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || '' }}
- name: Publish
uses: gradle/gradle-build-action@v2
with:
arguments: getTimestamp :${{ needs.common.outputs.version_name }}:publish -Ptype=${{ needs.common.outputs.version_type }}
generate-job-summary: false
env:
ORG_GRADLE_PROJECT_MAVEN_URL: ${{ vars.MAVEN_URL }}
ORG_GRADLE_PROJECT_MAVEN_USER: ${{ secrets.MAVEN_USER }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
discord:
name: Send status to discord
runs-on: ubuntu-latest
needs: [common, testjdks, publish]
if: ${{ always() && inputs.publish }}
steps:
- name: Create finish discord embed json
id: discord_embed_finish
run: |
echo "discord_embed<<EOF" >> $GITHUB_OUTPUT
echo "$DISCORD_EMBED" | jq 'map(. + {"title": $ENV.RESULT, "color": $ENV.COLOR}) | map(.fields += if $ENV.VERSION != "false" then [{"name": "Version", "value": $ENV.VERSION}] else [] end)' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
RESULT: ${{ needs.common.result == 'success' && needs.testjdks.result == 'success' && needs.publish.result == 'success' && 'Success' || 'Failed' }}
COLOR: ${{ needs.common.result == 'success' && needs.testjdks.result == 'success' && needs.publish.result == 'success' && 0x28F65A || 0xF53B27 }}
VERSION: ${{ needs.publish.result == 'success' && format('{0}-{1}', needs.common.outputs.version_name, needs.publish.outputs.timestamp) }}
DISCORD_EMBED: ${{ needs.common.outputs.discord_embed }}
- name: Notify discord of finish
uses: Ilshidur/[email protected]
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_USERNAME: GitHub Actions
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
DISCORD_EMBEDS: ${{ steps.discord_embed_finish.outputs.discord_embed }}