-
Notifications
You must be signed in to change notification settings - Fork 0
314 lines (265 loc) · 8.58 KB
/
collect-and-publish.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
name: collect and publish
on:
workflow_dispatch:
push:
branches:
- dev/1.12.2
release:
types:
- prereleased
- released
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
load-release-properties:
name: load packages name and md5 of submodules
if: startsWith(github.ref_name, 'release')
runs-on: self-hosted
outputs:
conf-name: ${{ steps.names.outputs.conf-name }}
scr-name: ${{ steps.names.outputs.scr-name }}
res-name: ${{ steps.names.outputs.res-name }}
md5-conf: ${{ steps.md5.outputs.mod-configs }}
md5-scr: ${{ steps.md5.outputs.scripts }}
md5-res: ${{ steps.md5.outputs.resources }}
steps:
- name: checkout repo
uses: actions/[email protected]
with:
submodules: recursive
- id: names
name: export package-names
run: |
CONF_VERSION="$(cat ./config/VERSION)"
SCR_VERSION="$(cat ./scripts/VERSION)"
RES_VERSION="$(cat ./resources/VERSION)"
echo "::set-output name=conf-name::ampilution-mod_configs-$MC_VERSION-$CONF_VERSION"
echo "::set-output name=scr-name::ampilution-scripts-$MC_VERSION-$SCR_VERSION"
echo "::set-output name=res-name::ampilution-resources-$MC_VERSION-$RES_VERSION"
- id: md5
name: load md5 of last versions
run: |
CONF_VERSION=$(curl $BASE_URL-mod_configs | jq -c '.versions | last')
SCRIPT_VERSION=$(curl $BASE_URL-scripts | jq -c '.versions | last')
RES_VERSION=$(curl $BASE_URL-resources | jq -c '.versions | last')
function get_md5 {
if [[ "$2" != "null" ]]; then
local VERSION=$(echo $2 | sed -e 's/"//g')
local MD5=$(curl $BASE_URL-$1/$VERSION | jq -c '.md5' | sed -e 's/"//g')
echo "::set-output name=$1::$MD5"
fi
}
get_md5 "mod-configs" $CONF_VERSION
get_md5 "scripts" $SCRIPT_VERSION
get_md5 "resources" $RES_VERSION
load-properties:
name: load packages name and md5
runs-on: self-hosted
outputs:
font-name: ${{ steps.names.outputs.font-name }}
ores-name: ${{ steps.names.outputs.ores-name }}
md5-font: ${{ steps.md5.outputs.fontfiles }}
md5-ores: ${{ steps.md5.outputs.oresources }}
steps:
- name: checkout repo
uses: actions/[email protected]
- id: names
name: export package-names
run: |
MC_VERSION="$(echo ${{ github.ref_name }} | cut -d '/' -f2)"
FONT_VERSION="$(cat ./fontfiles/VERSION)"
ORES_VERSION="$(cat ./oresources/VERSION)"
if [[ $(echo ${{ github.ref_name }} | cut -d '/' -f1) == dev ]]; then
FONT_VERSION="$(echo $FONT_VERSION-DEV-${{ github.run_number }})"
ORES_VERSION="$(echo $ORES_VERSION-DEV-${{ github.run_number }})"
fi
echo "::set-output name=font-name::ampilution-fontfiles-$MC_VERSION-$FONT_VERSION"
echo "::set-output name=ores-name::ampilution-oresources-$MC_VERSION-$ORES_VERSION"
- id: md5
name: load md5 of last versions
run: |
BASE_URL="https://solder.eratiem.net/api/mod/ampilution"
FONT_VERSION=$(curl -s $BASE_URL-fontfiles | jq -cr '.versions | last')
ORES_VERSION=$(curl -s $BASE_URL-oresources | jq -cr '.versions | last')
function get_md5 {
if [[ "$2" != "null" ]]; then
local MD5=$(curl -s $BASE_URL-$1/$2 | jq -cr '.md5')
echo "::set-output name=$1::$MD5"
fi
}
get_md5 "fontfiles" $FONT_VERSION
get_md5 "oresources" $ORES_VERSION
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*
pack-conf:
name: collect config
runs-on: self-hosted
if: startsWith(github.ref_name, 'release')
needs: load-release-properties
steps:
- name: checkout repo
uses: actions/[email protected]
with:
submodules: recursive
- name: move files
run: |
mkdir ./zip
mv ./config ./zip/
- name: collect zip
uses: actions/upload-artifact@v3
with:
name: ${{ needs.load-release-properties.outputs.conf-name }}
if-no-files-found: error
path: |
./zip/
!./zip/config/VERSION
!./zip/config/.gitignore
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*
pack-scr:
name: collect scripts
runs-on: self-hosted
if: startsWith(github.ref_name, 'release')
needs: load-release-properties
steps:
- name: checkout repo
uses: actions/[email protected]
with:
submodules: recursive
- name: move files
run: |
mkdir ./zip
mv ./scripts ./zip/
- name: collect zip
uses: actions/upload-artifact@v3
with:
name: ${{ needs.load-release-properties.outputs.scr-name }}
if-no-files-found: error
path: |
./zip/
!./zip/scripts/VERSION
!./zip/scripts/.gitignore
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*
pack-res:
name: collect resources
runs-on: self-hosted
if: startsWith(github.ref_name, 'release')
needs: load-release-properties
steps:
- name: checkout repo
uses: actions/[email protected]
with:
submodules: recursive
- name: move files
run: |
mkdir ./zip
mv ./resources ./zip/
- name: collect zip
uses: actions/upload-artifact@v3
with:
name: ${{ needs.load-release-properties.outputs.res-name }}
if-no-files-found: error
path: |
./zip/
!./zip/resources/VERSION
!./zip/resources/.gitignore
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*
pack-fonts:
name: collect fontfiles
runs-on: self-hosted
needs: load-properties
steps:
- name: checkout repo
uses: actions/[email protected]
- name: move files
run: |
mkdir ./zip
mv ./fontfiles ./zip/
- name: collect zip
uses: actions/upload-artifact@v3
with:
name: ${{ needs.load-properties.outputs.font-name }}
if-no-files-found: error
path: |
./zip/
!./zip/fontfiles/VERSION
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*
pack-ores:
name: collect oresources
runs-on: self-hosted
needs: load-properties
steps:
- name: checkout repo
uses: actions/[email protected]
- name: move files
run: |
mkdir ./zip
mv ./oresources ./zip/
- name: collect zip
uses: actions/upload-artifact@v3
with:
name: ${{ needs.load-properties.outputs.ores-name }}
if-no-files-found: error
path: |
./zip/
!./zip/oresources/VERSION
!./zip/oresources/.gitignore
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*
publish-to-solder:
name: publish to solder
runs-on: self-hosted
if: ${{ always() }}
needs:
- load-properties
- load-release-properties
- pack-fonts
- pack-ores
- pack-conf
- pack-scr
- pack-res
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: get artifacts
uses: actions/download-artifact@v3
- name: pack artifacts
run: |
PACKAGES=(*)
echo $PACKAGES
mkdir ./zip
mkdir ./upload
for package in "${PACKAGES[@]}"; do
mv ./$package ./zip
zip -r ./upload/$package.zip ./zip
rm -r ./zip/*
done
- name: upload to solder
run: |
cd ./upload
PACKAGES=(*)
for package in "${PACKAGES[@]}"; do
echo "Upload $package"
lftp -c "open --user ${{ secrets.FTP_USER }} --password ${{ secrets.FTP_PASSWORD }} ${{ secrets.MOD_REPOSITORY }}; put ./$package -o ./$( echo ${{ secrets.MOD_REPOSITORY }} | cut -f3 -d '/' )/mods/$(echo $package | cut -f1-2 -d '-')/"
done
- name: clean up
run: |
rm -rf ./*
rm -rf ./.??*