-
Notifications
You must be signed in to change notification settings - Fork 4
262 lines (222 loc) · 8.59 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
name: Build
run-name: Build #${{ github.run_number }} by @${{ github.actor }}
env:
RELEASE_TYPE: "release"
MC_VERSION: "1.12.2"
on:
push:
branches:
- pakku
# tags:
# - "*.*.*"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
info:
name: Project Info
runs-on: ubuntu-latest
outputs:
project_version: ${{ steps.project_version.outputs.tag }}
project_name: ${{ steps.project_name.outputs.value }}
changelog: ${{ steps.changelog.outputs.description }}
diff: ${{ steps.lockfile.outputs.diff }}
release_type: ${{ env.RELEASE_TYPE }}
mc_version: ${{ env.MC_VERSION }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Check lockfile
shell: bash
run: |
set +e
echo "🔎 Getting modpack info..."
if [ ! -f pakku-lock.json ]; then
echo "::error::Could not find pakku-lock.json" && exit 1
else
echo "✔️ pakku-lock.json"
fi
if [ ! -f pakku.json ]; then
echo "::error::Could not find pakku.json" && exit 1
else
echo "✔️ pakku.json"
fi
- name: Get previous lockfile
id: lockfile
shell: bash
run: |
set +e
echo "🔎 Getting previous lockfile..."
if [ "$latest_tag" = ${{ github.ref_name }} ]; then
latest_tag_prev=$(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)
latest_tagged_commit=$(git rev-list -n 1 --pretty=format:"%h" $latest_tag_prev | sed -n 2p)
if git cat-file -e $latest_tagged_commit:./pakku-lock.json; then
git show $latest_tagged_commit:./pakku-lock.json > ./pakku-lock-prev.json
java -jar ./pakku.jar diff -v --markdown PROJECTS_DIFF.md ./pakku-lock-pre.json ./pakku-lock.json
else
echo "❌ File pakku-lock.json not found in previous tag"
fi
fi
if [ ! -f PROJECTS_DIFF.md ]; then
touch PROJECTS_DIFF.md
fi
{
echo 'diff<<EOF'
cat -v --show-nonprinting PROJECTS_DIFF.md
echo EOF
} >> "$GITHUB_OUTPUT"
- 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: "WyriHaximus/[email protected]"
with:
fallback: build.${{ github.run_number }}
- name: Changelog Parser
id: changelog
uses: coditory/[email protected]
with:
path: CHANGELOG.md
- name: Generate list using Markdown
run: |
echo "📃 Project Name=${{ steps.project_name.outputs.value }}" >> $GITHUB_STEP_SUMMARY
echo "📃 Project Version=${{ steps.project_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "📃 MC Versions=${{ env.MC_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "📃 Release Type=${{ env.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.changelog.outputs.description }}" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.lockfile.outputs.diff }}" >> $GITHUB_STEP_SUMMARY
build-modpack:
name: Build Modpack
runs-on: ubuntu-latest
needs: [info]
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
sed -i -e "s/DEV/${{ needs.info.outputs.project_version }}/g" pakku.json
- 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: |
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_name }}-${{ needs.info.outputs.project_version }}-curseforge
path: ./build/curseforge/${{ needs.info.outputs.project_name }}-${{ needs.info.outputs.project_version }}-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_name }}-${{ needs.info.outputs.project_version }}-modrinth
path: ./build/modrinth/${{ needs.info.outputs.project_name }}-${{ needs.info.outputs.project_version }}-modrinth.mrpack
if-no-files-found: warn
build-server:
name: Build Server Pack
runs-on: ubuntu-latest
needs: [info]
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
sed -i -e "s/DEV/${{ needs.info.outputs.project_version }}/g" pakku.json
- 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/* ./
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_name }}-${{ needs.info.outputs.project_version }}-serverpack
path: ./build/serverpack/${{ needs.info.outputs.project_name }}-${{ needs.info.outputs.project_version }}-serverpack.zip
if-no-files-found: error
build-multimc:
name: Build MultiMC Pack
runs-on: ubuntu-latest
needs: [info]
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
- 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: |
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_name }}-${{ needs.info.outputs.project_version }}-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_name }}-${{ needs.info.outputs.project_version }}-multimc
path: .pakku/multimc-overrides/${{ needs.info.outputs.project_name }}-${{ needs.info.outputs.project_version }}-multimc.zip
if-no-files-found: error
release:
name: Release
needs: [info, build-modpack, build-server, build-multimc]
# if: startsWith(github.ref, 'refs/tags/')
uses: ./.github/workflows/release.yml
with:
project_name: ${{ needs.info.outputs.project_name }}
project_version: ${{ needs.info.outputs.project_version }}
mc_version: ${{ needs.info.outputs.mc_version }}
release_type: ${{ needs.info.outputs.release_type }}
changelog: ${{ needs.info.outputs.changelog }}
diff: ${{ needs.info.outputs.diff }}
secrets: inherit