-
Notifications
You must be signed in to change notification settings - Fork 4
490 lines (420 loc) · 17.5 KB
/
build.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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
name: Project Build
run-name: "Project Build #${{ github.run_number }}"
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
RELEASE_TYPE: "release"
MINECRAFT_VERSION: "1.12.2"
jobs:
info:
name: 🖥️ Project Info
runs-on: ubuntu-latest
outputs:
project_version: ${{ steps.project_version.outputs.value }}
project_name: ${{ steps.project_name.outputs.value }}
project_full_name: ${{ steps.project_name.outputs.value }}-${{ steps.project_version.outputs.value }}
changelog: ${{ steps.changelog.outputs.description }}
diff: ${{ steps.read_diff.outputs.diff }}
release_type: ${{ env.RELEASE_TYPE }}
minecraft_version: ${{ env.MINECRAFT_VERSION }}
exists: ${{ steps.check_tag.outputs.exists }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: 🔍 Check pakku-lock.json
id: check_pakku_lock
shell: bash
run: |
if [ ! -f pakku-lock.json ]; then
echo "❌ Could not find pakku-lock.json" && exit 1
else
echo "✔️ pakku-lock.json"
fi
- name: 🔍 Check pakku.json
id: check_pakku
shell: bash
run: |
if [ ! -f pakku.json ]; then
echo "❌ Could not find pakku.json" && exit 1
else
echo "✔️ pakku.json"
fi
- name: 📈 Get latest tag
id: latest_tag
shell: bash
run: |
tag=$(git describe --tags --abbrev=0)
if [ -z "$tag" ]; then
echo "❌ Latest tag not found" && exit 1
else
echo "✔️ Latest tag found: $tag"
echo "tag=$tag" >> $GITHUB_OUTPUT
fi
- name: 🔍 Check pakku-lock.json in previous tag
id: check_pakku_lock_prev
shell: bash
run: |
if ! git ls-tree -r ${{ steps.latest_tag.outputs.tag }} -- ./pakku-lock.json &> /dev/null; then
echo "❌ File pakku-lock.json not found in previous tag" && exit 1
else
echo "✔️ File pakku-lock.json found in previous tag"
fi
- name: 📁 Copy pakku-lock.json from previous tag
id: copy_pakku_lock_prev
shell: bash
run: |
git show tags/${{ steps.latest_tag.outputs.tag }}:./pakku-lock.json > ./pakku-lock-prev.json
if [ -s ./pakku-lock-prev.json ]; then
echo "✔️ File pakku-lock-prev.json created"
else
echo "❌ Error: File pakku-lock-prev.json is empty or not created" && exit 1
fi
- name: 📦 Download pakku.jar
id: download_pakku
shell: bash
run: |
curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J
echo "✔️ Downloaded pakku.jar "
- name: 🔄 Run pakku diff
id: pakku_diff
shell: bash
run: |
java -jar pakku.jar diff -v --markdown PROJECTS_DIFF.md ./pakku-lock-prev.json ./pakku-lock.json
if [ -f PROJECTS_DIFF.md ]; then
echo "✔️ Comparison completed"
else
echo "❌ Error: File PROJECTS_DIFF.md not created" && exit 1
fi
- name: 📝 Read PROJECTS_DIFF.md to variable
id: read_diff
shell: bash
run: |
echo "📝 Reading PROJECTS_DIFF.md to variable..."
{
echo 'diff<<EOF'
cat -v PROJECTS_DIFF.md
echo EOF
} >> "$GITHUB_OUTPUT"
echo "✔️ Diff content read to variable"
- name: 📊 Get Project Name
id: project_name
uses: ActionsTools/[email protected]
with:
file_path: "pakku.json"
prop_path: "name"
- name: 📊 Get Project Version
id: project_version
uses: ActionsTools/[email protected]
with:
file_path: "pakku.json"
prop_path: "version"
- name: 📊 Get Minecraft Version
id: minecraft_version
uses: ActionsTools/[email protected]
with:
file_path: "pakku-lock.json"
prop_path: "mc_versions"
- name: 📄 Changelog Parser
id: changelog
uses: coditory/[email protected]
with:
path: CHANGELOG.md
- name: 📈 Upload Diff
id: upload_diff
if: ${{ steps.read_diff.outputs.diff != '' }}
uses: actions/[email protected]
with:
name: Mods-diff
path: PROJECTS_DIFF.md
- name: 🔍 Check if tag exists
uses: mukunku/[email protected]
id: check_tag
with:
tag: ${{ steps.project_version.outputs.value }}
- name: 📝 Generate Github Summary
run: |
echo "📃 **Name**: ${{ steps.project_name.outputs.value }}" >> $GITHUB_STEP_SUMMARY
echo "📃 **Release**: ${{ steps.project_version.outputs.value }}" >> $GITHUB_STEP_SUMMARY
echo "📃 **Release Type**: ${{ env.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
echo "📃 **Game Version**: ${{ env.MINECRAFT_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.changelog.outputs.description }}" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ steps.read_diff.outputs.diff != '' }}" ]; then
echo "${{ steps.read_diff.outputs.diff }}" >> $GITHUB_STEP_SUMMARY
fi
build-modpack:
name: 📦 Build Modpack
needs: [info]
runs-on: ubuntu-latest
if: needs.info.outputs.exists != 'true'
steps:
- name: Checkout
uses: actions/[email protected]
- name: 🔄 Replace strings
shell: bash
run: |
set +e
grooovy="./groovy/runConfig.json"
cat <<< $(jq '.debug = false' $grooovy) > $grooovy
VERSION=${{ needs.info.outputs.project_version }}
sed -i -e "s/DEV/${VERSION}/g" groovy/runConfig.json
sed -i -e "s/DEV/${VERSION}/g" config/fancymenu/customization/gui_main_menu.txt
# - name: Cache pakku
# uses: actions/[email protected]
# with:
# path: build/.cache
# key: ${{ runner.OS }}-pakku-cache-${{ hashFiles('build/.cache/') }}
# restore-keys: ${{ runner.OS }}-pakku-cache-
- name: 📦 Export modpack
run: |
curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J
java -jar pakku.jar export
- name: 📁 Rename artifact curseforge
run: |
cd ./build/curseforge/
mv *.zip $(basename -s .zip *.zip)-curseforge.zip
- name: 🚀 Upload artifact CurseForge
uses: actions/[email protected]
with:
name: ${{ needs.info.outputs.project_full_name }}-curseforge
path: ./build/curseforge/${{ needs.info.outputs.project_full_name }}-curseforge.zip
if-no-files-found: error
- name: 📁 Rename artifact modrinth
run: |
cd ./build/modrinth/
mv *.mrpack $(basename -s .mrpack *.mrpack)-modrinth.mrpack
- name: 🚀 Upload artifact modrinth
uses: actions/[email protected]
with:
name: ${{ needs.info.outputs.project_full_name }}-modrinth
path: ./build/modrinth/${{ needs.info.outputs.project_full_name }}-modrinth.mrpack
if-no-files-found: warn
build-server:
name: 📦 Build Server
needs: [info]
runs-on: ubuntu-latest
if: needs.info.outputs.exists != 'true'
steps:
- name: Checkout
uses: actions/[email protected]
- name: 🔄 Replace strings
shell: bash
run: |
set +e
grooovy="./groovy/runConfig.json"
cat <<< $(jq '.debug = false' $grooovy) > $grooovy
VERSION=${{ needs.info.outputs.project_version }}
sed -i -e "s/DEV/${VERSION}/g" groovy/runConfig.json
sed -i -e "s/DEV/${VERSION}/g" config/fancymenu/customization/gui_main_menu.txt
# - name: Cache pakku
# uses: actions/[email protected]
# with:
# path: build/.cache
# key: ${{ runner.OS }}-pakku-cache-${{ hashFiles('build/.cache/') }}
# restore-keys: ${{ runner.OS }}-pakku-cache-
- name: 📦 Export modpack
run: |
mv -vf ./.pakku/server-overrides/* ./
curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J
java -jar pakku.jar export
- name: 📁 Rename artifact server
run: |
cd ./build/serverpack/
mv *.zip $(basename -s .zip *.zip)-serverpack.zip
- name: 🚀 Upload artifact server
uses: actions/[email protected]
with:
name: ${{ needs.info.outputs.project_full_name }}-serverpack
path: ./build/serverpack/${{ needs.info.outputs.project_full_name }}-serverpack.zip
if-no-files-found: error
build-multimc:
name: 📦 Build MultiMC
needs: [info]
runs-on: ubuntu-latest
if: needs.info.outputs.exists != 'true'
steps:
- name: Checkout
uses: actions/[email protected]
- name: 🔄 Replace strings
shell: bash
run: |
set +e
grooovy="./groovy/runConfig.json"
cat <<< $(jq '.debug = false' $grooovy) > $grooovy
VERSION=${{ needs.info.outputs.project_version }}
sed -i -e "s/DEV/${VERSION}/g" groovy/runConfig.json
sed -i -e "s/DEV/${VERSION}/g" config/fancymenu/customization/gui_main_menu.txt
sed -i -e "s/DEV/${VERSION}/g" .pakku/multimc-overrides/instance.cfg
# - name: Cache pakku
# uses: actions/[email protected]
# with:
# path: build/.cache
# key: ${{ runner.OS }}-pakku-cache-${{ hashFiles('build/.cache/') }}
# restore-keys: ${{ runner.OS }}-pakku-cache-
- name: 📦 Export
run: |
curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J
java -jar pakku.jar --debug fetch
java -jar pakku.jar --debug export
- name: 📁 Move files
run: |
ls
mkdir -p .pakku/multimc-overrides/flame
mv -vf ./build/.cache/curseforge/manifest.json .pakku/multimc-overrides/flame/manifest.json
mv -vf ./build/.cache/curseforge/overrides .pakku/multimc-overrides/.minecraft
mv -vf ./mods .pakku/multimc-overrides/.minecraft/mods
cd .pakku/multimc-overrides/
zip -r ${{ needs.info.outputs.project_full_name }}-multimc.zip icon.png mmc-pack.json instance.cfg .minecraft/ flame/
- name: 🚀 Upload zip multimc
uses: actions/[email protected]
with:
name: ${{ needs.info.outputs.project_full_name }}-multimc
path: .pakku/multimc-overrides/${{ needs.info.outputs.project_full_name }}-multimc.zip
if-no-files-found: error
release-curseforge:
name: 🚀 Release to CurseForge
needs: [info, build-modpack, build-server]
runs-on: ubuntu-latest
outputs:
id: ${{ steps.release.outputs.id }}
steps:
- name: 🔒 Check if CURSEFORGE_TOKEN exist
shell: bash
run: |
if [ "${{ secrets.CURSEFORGE_TOKEN }}" == '' ]; then
echo '::error::No value found for secret key `CURSEFORGE_TOKEN`. See https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository' && exit 1
fi
- name: 📦 Download artifact curseforge
uses: actions/[email protected]
with:
name: ${{ needs.info.outputs.project_full_name }}-curseforge
- name: 📦 Download artifact server
uses: actions/[email protected]
with:
name: ${{ needs.info.outputs.project_full_name }}-serverpack
- name: 🚀 Upload Curseforge
id: release
uses: Xikaro/[email protected]
with:
api-token: ${{ secrets.CURSEFORGE_TOKEN }}
project-id: ${{ vars.CURSEFORGE_ID }}
display-name: ${{ needs.info.outputs.project_full_name }}
modpack-path: ${{ needs.info.outputs.project_full_name }}-curseforge.zip
server-display-name: ${{ needs.info.outputs.project_full_name }}-serverpack
modpack-server-path: ${{ needs.info.outputs.project_full_name }}-serverpack.zip
changelog: |
${{ needs.info.outputs.changelog }}
${{ needs.info.outputs.diff }}
changelog-format: markdown
game-version: ${{ needs.info.outputs.minecraft_version }}
release-type: ${{ needs.info.outputs.release_type }}
# release-modrinth:
# name: 🚀 Release to Modrinth
# needs: [info, build-modpack, build-server]
# runs-on: ubuntu-latest
# steps:
# - name: 🔒 Check if MODRINTH_API_TOKEN exist
# shell: bash
# run: |
# if [ "${{ secrets.MODRINTH_TOKEN }}" == '' ]; then
# echo '::error::No value found for secret key `MODRINTH_TOKEN`. See https://docs.github.com/en/ actionssecurity-guides/ encrypted-secrets#creating-encrypted-secrets-for-a-repository' && exit 1
# fi
# - name: 📦 Download artifact modrinth
# uses: actions/[email protected]
# with:
# name: ${{ needs.info.outputs.project_full_name }}-modrinth
# - name: 📦 Download artifact server
# uses: actions/[email protected]
# with:
# name: ${{ needs.info.outputs.project_full_name }}-serverpack
# - name: 🚀 Upload Modrinth
# id: release
# uses: Xikaro/[email protected]
# with:
# api-token: ${{ secrets.MODRINTH_TOKEN }}
# project-id: ${{ vars.MODRINTH_ID }}
# modpack-path: ${{ needs.info.outputs.project_full_name }}-modrinth.mrpack
# modpack-server-path: ${{ needs.info.outputs.project_full_name }}-serverpack.zip
# changelog: ${{ needs.info.outputs.changelog }}
# changelog-format: markdown
# game-version: ${{ needs.info.outputs.minecraft_version }}
# display-name: ${{ needs.info.outputs.project_full_name }}
# server-display-name: ${{ needs.info.outputs.project_full_name }}-serverpack
# release-type: ${{ needs.info.outputs.release_type }}
release-github:
name: 🚀 Release to GitHub
needs: [info, build-modpack, build-server, build-multimc]
runs-on: ubuntu-latest
outputs:
url: ${{ steps.release.outputs.url }}
steps:
- name: 📦 Checkout
uses: actions/[email protected]
- name: 📦 Download artifact
uses: actions/[email protected]
with:
merge-multiple: true
- name: 🚫 Сlose fixed in dev
uses: Xikaro/close-issues-based-on-label@master
env:
LABEL: "2. Status: In Dev"
COMMENT: In ${{ needs.info.outputs.project_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Format diff
id: format_diff
if: ${{ needs.info.outputs.diff != '' }}
uses: roamingowl/[email protected]
with:
template: |
```markdown
${{ needs.info.outputs.diff }}
```
- name: 🚀 Create release
id: release
uses: softprops/[email protected]
with:
name: ${{ needs.info.outputs.project_version }}
tag_name: ${{ needs.info.outputs.project_version }}
body: |
${{ needs.info.outputs.changelog }}
${{ steps.format_diff.outputs.text }}
files: |
${{ needs.info.outputs.project_full_name }}-curseforge.zip
${{ needs.info.outputs.project_full_name }}-serverpack.zip
${{ needs.info.outputs.project_full_name }}-multimc.zip
prerelease: ${{ needs.info.outputs.release_type != 'release' }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
discord-message:
name: 📱 Discord Message
needs: [info, release-curseforge, release-github]
runs-on: ubuntu-latest
steps:
- name: ✂️ Truncate Changelog
id: truncated
uses: cisox/[email protected]
with:
text: '${{ needs.info.outputs.changelog }}'
max_chars: '1450'
- name: 📨 Send Discord message
uses: hugoalh/[email protected]
with:
key: ${{ secrets.DISCORD_RELEASES }}
username: "TerraFirmaGreg"
avatar_url: "https://raw.githubusercontent.com/TerraFirmaGreg-Team/.github/main/branding/logo.png"
content_links_no_embed: .+
content: |
**Release**: `${{ needs.info.outputs.project_version }}`
**Release Type**: `${{ needs.info.outputs.release_type }}`
**Game Version**: `${{ needs.info.outputs.minecraft_version }}`
[CurseForge](https://www.curseforge.com/minecraft/modpacks/terrafirmagreg-vintage/files/${{ needs.release-curseforge.outputs.id }}) • [GitHub](${{ needs.release-github.outputs.url }}) • [Issues](https://github.com/${{ github.repository }}/issues)
```markdown
${{ steps.truncated.outputs.text }}
- ...```
** [Read more...](${{ needs.release-github.outputs.url }}) **