-
Notifications
You must be signed in to change notification settings - Fork 481
413 lines (397 loc) · 14.8 KB
/
generate-symbols.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
name: Generate symbols
on:
workflow_dispatch:
inputs:
structures_ref:
description: Structures branch to build from and update
required: true
default: master
version:
description: DF version (can be "auto" if channel is steam)
required: true
platform:
description: Target OS platform
type: choice
required: true
default: all
options:
- all
- windows
- linux
channel:
description: DF distribution channel
type: choice
required: true
default: all
options:
- all
- steam
- itch
- classic
df_steam_branch:
description: DF Steam branch to read from (if processing Steam distribution channel)
required: true
type: choice
default: default
options:
- default
- testing
- adventure_test
- beta
steam_branch:
description: DFHack Steam branch to deploy to (leave blank to skip deploy)
type: string
jobs:
package-linux:
uses: ./.github/workflows/build-linux.yml
if: inputs.platform == 'all' || inputs.platform == 'linux'
with:
dfhack_ref: ${{ github.ref }}
structures_ref: ${{ inputs.structures_ref }}
artifact-name: dfhack-symbols-linux64-build
append-date-and-hash: false
cache-id: release
cache-readonly: true
plugins: false
secrets: inherit
package-win64:
uses: ./.github/workflows/build-windows.yml
if: (inputs.platform == 'all' || inputs.platform == 'windows') && inputs.version == 'auto'
with:
dfhack_ref: ${{ github.ref }}
structures_ref: ${{ inputs.structures_ref }}
artifact-name: dfhack-symbols-windows64-build
append-date-and-hash: false
cache-id: release
cache-readonly: true
plugins: false
secrets: inherit
generate-linux:
name: Generate linux64 symbols
runs-on: ubuntu-latest
if: inputs.platform == 'all' || inputs.platform == 'linux'
needs:
- package-linux
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install \
ansifilter \
libsdl2-2.0-0 \
libsdl2-image-2.0-0
- name: Clone structures
uses: actions/checkout@v4
with:
repository: DFHack/df-structures
ref: ${{ inputs.structures_ref }}
token: ${{ secrets.DFHACK_GITHUB_TOKEN }}
path: xml
- name: Download DFHack
uses: actions/download-artifact@v4
with:
name: dfhack-symbols-linux64-build
- name: Start X server
run: Xvfb :0 -screen 0 1600x1200x24 &
# Steam
- name: Setup steamcmd
if: inputs.channel == 'all' || inputs.channel == 'steam'
id: steamcmd
uses: CyberAndrii/setup-steamcmd@v1
- name: Generate Steam symbols
if: inputs.channel == 'all' || inputs.channel == 'steam'
env:
DISPLAY: :0
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_CONFIG_VDF: ${{ secrets.STEAM_CONFIG_VDF }}
STEAM_DF_TESTING: ${{ secrets.STEAM_DF_TESTING }}
STEAM_DF_ADVENTURE_TEST: ${{ secrets.STEAM_DF_ADVENTURE_TEST }}
run: |
mkdir DF_steam
mkdir -p $HOME/Steam/config
echo "$STEAM_CONFIG_VDF" | base64 -d >$HOME/Steam/config/config.vdf
echo "DF steam branch: ${{ inputs.df_steam_branch }}"
if [ "${{ inputs.df_steam_branch }}" = "default" ]; then
BETA_PARAMS=""
elif [ "${{ inputs.df_steam_branch }}" = "testing" ]; then
BETA_PARAMS="-beta testing -betapassword $STEAM_DF_TESTING"
elif [ "${{ inputs.df_steam_branch }}" = "adventure_test" ]; then
BETA_PARAMS="-beta adventure_test -betapassword $STEAM_DF_ADVENTURE_TEST"
else
BETA_PARAMS="-beta ${{ inputs.df_steam_branch }}"
fi
${{ steps.steamcmd.outputs.executable }} \
+@ShutdownOnFailedCommand 1 \
+force_install_dir $PWD/DF_steam \
+login $STEAM_USERNAME \
"+app_update 975370 $BETA_PARAMS validate" \
+quit
tar xjf dfhack-symbols-linux64-build.tar.bz2 -C DF_steam
xml/symbols_gen_linux.sh ${{ inputs.version == 'auto' && '50.0' || inputs.version }} STEAM DF_steam
if [ "${{ inputs.version }}" = "auto" ]; then
while pgrep dwarfort; do
echo "waiting for DF to exit"
sleep 0.5
done
cp xml/symbols.xml DF_steam/hack
cd DF_steam
DFHACK_DISABLE_CONSOLE=1 ./dfhack &
while ! ./dfhack-run lua 'print(scr)' | fgrep 'viewscreen_titlest' 2>/dev/null; do
echo "waiting for DF to start"
sleep 0.5
done
df_ver=`./dfhack-run lua 'print(dfhack.gui.getDFViewscreen(true).str_version)' | ansifilter`
echo "Found version string: '$df_ver'"
sed -i "s/v0.50.0 linux64 STEAM/v0.$df_ver linux64 STEAM/" ../xml/symbols.xml
fi
# Itch
- name: Generate Itch symbols
if: (inputs.channel == 'all' || inputs.channel == 'itch') && inputs.version != 'auto'
env:
DISPLAY: :0
ITCH_API_KEY: ${{ secrets.ITCH_API_KEY }}
run: |
mkdir DF_itch
pip install itch-dl
minor=$(echo "${{ inputs.version }}" | cut -d. -f1)
patch=$(echo "${{ inputs.version }}" | cut -d. -f2)
itch-dl https://kitfoxgames.itch.io/dwarf-fortress --download-to . --api-key $ITCH_API_KEY
tar xjf "kitfoxgames/dwarf-fortress/files/dwarf_fortress_${minor}_${patch}_linux.tar.bz2" -C DF_itch
tar xjf dfhack-symbols-linux64-build.tar.bz2 -C DF_itch
xml/symbols_gen_linux.sh ${{ inputs.version }} ITCH DF_itch
# Classic
- name: Generate Classic symbols
if: (inputs.channel == 'all' || inputs.channel == 'classic') && inputs.version != 'auto'
env:
DISPLAY: :0
run: |
mkdir DF_classic
minor=$(echo "${{ inputs.version }}" | cut -d. -f1)
patch=$(echo "${{ inputs.version }}" | cut -d. -f2)
fname="df_${minor}_${patch}_linux.tar.bz2"
wget "https://www.bay12games.com/dwarves/${fname}"
tar xjf "${fname}" -C DF_classic
tar xjf dfhack-symbols-linux64-build.tar.bz2 -C DF_classic
xml/symbols_gen_linux.sh ${{ inputs.version }} CLASSIC DF_classic
# Finalize
- name: Merge updates
run: |
cd xml
if ! git diff --exit-code; then
git stash
git pull
git stash pop
fi
- name: Commit symbol updates
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Auto-update symbols
repository: xml
commit_user_name: DFHack-Urist via GitHub Actions
commit_user_email: [email protected]
generate-windows:
name: Generate win64 symbols
runs-on: ubuntu-latest
if: inputs.platform == 'all' || inputs.platform == 'windows'
steps:
- name: Install dependencies
run: pip install pefile
- name: Clone structures
uses: actions/checkout@v4
with:
repository: DFHack/df-structures
ref: ${{ inputs.structures_ref }}
token: ${{ secrets.DFHACK_GITHUB_TOKEN }}
path: xml
- name: Clone df_misc
uses: actions/checkout@v4
with:
repository: DFHack/df_misc
path: df_misc
- name: Clone metasm
uses: actions/checkout@v4
with:
repository: jjyg/metasm
path: metasm
# Steam
- name: Setup steamcmd
if: inputs.channel == 'all' || inputs.channel == 'steam'
id: steamcmd
uses: CyberAndrii/setup-steamcmd@v1
- name: Generate Steam symbols
if: inputs.channel == 'all' || inputs.channel == 'steam'
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_CONFIG_VDF: ${{ secrets.STEAM_CONFIG_VDF }}
STEAM_DF_TESTING: ${{ secrets.STEAM_DF_TESTING }}
STEAM_DF_ADVENTURE_TEST: ${{ secrets.STEAM_DF_ADVENTURE_TEST }}
run: |
mkdir DF_steam
mkdir -p $HOME/Steam/config
echo "$STEAM_CONFIG_VDF" | base64 -d >$HOME/Steam/config/config.vdf
echo "DF steam branch: ${{ inputs.df_steam_branch }}"
if [ "${{ inputs.df_steam_branch }}" = "default" ]; then
BETA_PARAMS=""
elif [ "${{ inputs.df_steam_branch }}" = "testing" ]; then
BETA_PARAMS="-beta testing -betapassword $STEAM_DF_TESTING"
elif [ "${{ inputs.df_steam_branch }}" = "adventure_test" ]; then
BETA_PARAMS="-beta adventure_test -betapassword $STEAM_DF_ADVENTURE_TEST"
else
BETA_PARAMS="-beta ${{ inputs.df_steam_branch }}"
fi
${{ steps.steamcmd.outputs.executable }} \
+@ShutdownOnFailedCommand 1 \
+@sSteamCmdForcePlatformType windows \
+force_install_dir $PWD/DF_steam \
+login $STEAM_USERNAME \
"+app_update 975370 $BETA_PARAMS validate" \
+quit
xml/symbols_gen_windows.sh ${{ inputs.version == 'auto' && '50.0' || inputs.version }} STEAM DF_steam
# Itch
- name: Generate Itch symbols
if: (inputs.channel == 'all' || inputs.channel == 'itch') && inputs.version != 'auto'
env:
ITCH_API_KEY: ${{ secrets.ITCH_API_KEY }}
run: |
mkdir DF_itch
pip install itch-dl
minor=$(echo "${{ inputs.version }}" | cut -d. -f1)
patch=$(echo "${{ inputs.version }}" | cut -d. -f2)
itch-dl https://kitfoxgames.itch.io/dwarf-fortress --download-to . --api-key $ITCH_API_KEY
unzip -d DF_itch "kitfoxgames/dwarf-fortress/files/dwarf_fortress_${minor}_${patch}_windows.zip"
xml/symbols_gen_windows.sh ${{ inputs.version }} ITCH DF_itch
# Classic
- name: Generate Classic symbols
if: (inputs.channel == 'all' || inputs.channel == 'classic') && inputs.version != 'auto'
run: |
mkdir DF_classic
minor=$(echo "${{ inputs.version }}" | cut -d. -f1)
patch=$(echo "${{ inputs.version }}" | cut -d. -f2)
fname="df_${minor}_${patch}_win.zip"
wget "https://www.bay12games.com/dwarves/${fname}"
unzip -d DF_classic "${fname}"
xml/symbols_gen_windows.sh ${{ inputs.version }} CLASSIC DF_classic
# Finalize
- name: Merge updates
run: |
cd xml
if ! git diff --exit-code; then
git stash
git pull
git stash pop
fi
- name: Commit symbol updates
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Auto-update symbols
repository: xml
commit_user_name: DFHack-Urist via GitHub Actions
commit_user_email: [email protected]
auto-ver-windows:
name: Autodetect DF version string (Windows)
if: (inputs.platform == 'all' || inputs.platform == 'windows') && (inputs.channel == 'all' || inputs.channel == 'steam') && inputs.version == 'auto'
needs:
- package-win64
- generate-windows
runs-on: windows-latest
steps:
- name: Clone structures
uses: actions/checkout@v4
with:
repository: DFHack/df-structures
ref: ${{ inputs.structures_ref }}
token: ${{ secrets.DFHACK_GITHUB_TOKEN }}
path: xml
- name: Download DFHack
uses: actions/download-artifact@v4
with:
name: dfhack-symbols-windows64-build
- name: Setup steamcmd
id: steamcmd
uses: CyberAndrii/setup-steamcmd@v1
- name: Update DF version string
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_CONFIG_VDF: ${{ secrets.STEAM_CONFIG_VDF }}
STEAM_DF_TESTING: ${{ secrets.STEAM_DF_TESTING }}
STEAM_DF_ADVENTURE_TEST: ${{ secrets.STEAM_DF_ADVENTURE_TEST }}
shell: bash
run: |
mkdir DF_steam
echo "$STEAM_CONFIG_VDF" | base64 -d >${{ steps.steamcmd.outputs.directory }}/config/config.vdf
echo "DF steam branch: ${{ inputs.df_steam_branch }}"
if [ "${{ inputs.df_steam_branch }}" = "default" ]; then
BETA_PARAMS=""
elif [ "${{ inputs.df_steam_branch }}" = "testing" ]; then
BETA_PARAMS="-beta testing -betapassword $STEAM_DF_TESTING"
elif [ "${{ inputs.df_steam_branch }}" = "adventure_test" ]; then
BETA_PARAMS="-beta adventure_test -betapassword $STEAM_DF_ADVENTURE_TEST"
else
BETA_PARAMS="-beta ${{ inputs.df_steam_branch }}"
fi
${{ steps.steamcmd.outputs.executable }} \
+@ShutdownOnFailedCommand 1 \
+@sSteamCmdForcePlatformType windows \
+force_install_dir $PWD/DF_steam \
+login $STEAM_USERNAME \
"+app_update 975370 $BETA_PARAMS validate" \
+quit
tar xjf ../dfhack-symbols-windows64-build.tar.bz2 -C DF_steam
cp xml/symbols.xml DF_steam/hack
cd DF_steam
"Dwarf Fortress.exe" &
while ! dfhack-run.exe lua 'print(scr)' | fgrep 'viewscreen_titlest' 2>/dev/null; do
echo "waiting for DF to start"
sleep 0.5
done
df_ver=`dfhack-run.exe lua 'print(dfhack.gui.getDFViewscreen(true).str_version)'`
echo "Found version string: '$df_ver'"
sed -i "s/v0.50.0 win64 STEAM/v0.$df_ver win64 STEAM/" ../xml/symbols.xml
- name: Merge updates
shell: bash
run: |
cd xml
if ! git diff --exit-code; then
git stash
git pull
git stash pop
fi
- name: Commit symbol updates
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Auto-update Windows DF version in symbols
repository: xml
commit_user_name: DFHack-Urist via GitHub Actions
commit_user_email: [email protected]
update-ref:
name: Update structures ref
runs-on: ubuntu-latest
needs:
- generate-linux
- auto-ver-windows
if: ${{ ! failure() }}
steps:
- name: Clone DFHack
uses: actions/checkout@v4
with:
token: ${{ secrets.DFHACK_GITHUB_TOKEN }}
- name: Update ref
shell: bash
run: |
git submodule update --init --no-single-branch library/xml
cd library/xml
git checkout ${{ inputs.structures_ref }}
git pull
echo DETECTED_DF_VER=`git diff symbols.xml | grep -E "^[+][^']+'v0[.]" | head -n1 | sed -r "s/.*name='v0.([^ ]+) .*/\1/"` >>$GITHUB_ENV
- name: Commit ref update
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Auto-update structures ref
commit_user_name: DFHack-Urist via GitHub Actions
commit_user_email: [email protected]
- name: Launch steam-deploy
if: inputs.steam_branch
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run steam-deploy.yml -R DFHack/dfhack -r ${{ github.ref }} -f version=${{ env.DETECTED_DF_VER }} -f steam_branch=${{ inputs.steam_branch }}