-
-
Notifications
You must be signed in to change notification settings - Fork 5
132 lines (102 loc) · 3.9 KB
/
BuildMultiplatform.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
name: Build Multiplatform
run-name: "Build Multiplatform #${{ github.run_number }}"
on:
push:
tags:
- 'v*'
branches:
- main
jobs:
modpack-info:
name: Modpack Info
runs-on: ubuntu-latest
outputs:
projectname: ${{ steps.info.outputs.projectname }}
projectsuffix: ${{ steps.info.outputs.projectsuffix }}
tag: ${{ steps.info.outputs.tag }}
diff: ${{ steps.info.outputs.diff }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get modpack info
id: info
shell: bash
run: |
set +e
# -- CHECK LOCKFILE --
if [ ! -f pakku-lock.json ]; then
echo "::error::Could not find pakku-lock.json" && exit 1
fi
manifestjson=`cat pakku-lock.json`
# -- PROJECT NAME --
projectname=`echo $(jq -r '.name' <<< "$manifestjson")`
echo "projectname=$projectname" >> $GITHUB_OUTPUT
# -- TAG --
latest_tag=$(git describe --tags --abbrev=0)
echo "tag=$latest_tag" >> $GITHUB_OUTPUT
# -- PROJECT SUFFIX --
if [[ ${{ startsWith(github.ref, 'refs/tags/v') }} == true ]]; then
echo "projectsuffix=$latest_tag" >> $GITHUB_OUTPUT
else
echo "projectsuffix=build.${{ github.run_number }}" >> $GITHUB_OUTPUT
fi
# -- DIFF --
previous_commit=$(git log -n 1 --skip 1 --pretty=format:"%h" -- $manifest)
git show $previous_commit:./pakku-lock.json > ./pakku-lock-prev.json
curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J
java -jar ./pakku.jar diff ./pakku-lock-prev.json ./pakku-lock.json --markdown PROJECTS_DIFF.md
# -- OUTPUT DIFF --
cat PROJECTS_DIFF.md >> $GITHUB_STEP_SUMMARY
{
echo 'diff<<EOF'
cat PROJECTS_DIFF.md
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Send Discord message
uses: "hugoalh/send-discord-webhook-ghaction@v6.0.2"
if: ${{ steps.info.outputs.diff != '' }}
with:
key: ${{ secrets.DISCORD_WEBHOOK }}
username: "GitHub"
avatar_url: "https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png"
embeds: |
[
{
"description": "${{ steps.info.outputs.diff }}",
"color": "Discord Blurple",
}
]
build-modpack:
name: Build Modpack
runs-on: ubuntu-latest
needs: [modpack-info]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Replace tokens
shell: bash
run: |
set +e
manifest="./pakku.json"
custom_window_title="./config/fancymenu/config.txt"
fancymenu="./config/fancymenu/customization/main_menu.txt"
rich_presence="./config/DiscordRPC.cfg"
grooovy="./groovy/runConfig.json"
perl -i -pe "s/\@version\@/${{ needs.modpack-info.outputs.projectsuffix }}/g" $manifest
perl -i -pe "s/\@version\@/${{ needs.modpack-info.outputs.projectsuffix }}/g" $custom_window_title
perl -i -pe "s/\@version\@/${{ needs.modpack-info.outputs.projectsuffix }}/g" $fancymenu
perl -i -pe "s/\@version\@/${{ needs.modpack-info.outputs.projectsuffix }}/g" $rich_presence
perl -i -pe "s/\@version\@/${{ needs.modpack-info.outputs.projectsuffix }}/g" $grooovy
cat <<< $(jq '.debug = false' $grooovy) > $grooovy
- name: Export modpack
run: |
mkdir build
curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J
java -jar ./pakku.jar export build
- name: Upload modpacks
uses: actions/upload-artifact@v4
with:
name: modpacks
path: build/