-
Notifications
You must be signed in to change notification settings - Fork 34
356 lines (325 loc) · 14.4 KB
/
compile-games.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
name: Compile Games
on:
repository_dispatch:
pull_request_target:
types: [opened, reopened, synchronize, labeled, unlabeled]
branches: [main]
jobs:
get-game-directory:
if: "!contains( github.event.pull_request.labels.*.name, 'compiled')"
runs-on: ubuntu-latest
env:
GAME_DIR:
GIT_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
GITHUB_CONTEXT: ${{ toJson(github) }}
outputs:
game-directory: ${{ steps.get-game-directory.outputs.game-directory }}
CSharpFound: ${{ steps.get-game-directory.outputs.CSharpFound }}
NoCSharpFound: ${{ steps.get-game-directory.outputs.NoCSharpFound }}
Number-of-games: ${{ steps.get-game-directory.outputs.Number-of-games }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
submodules: "recursive"
- id: get-game-directory
run: |
cd $GITHUB_WORKSPACE
if [ "${GIT_BASE_REPO}" == "thoth-tech/arcade-games" ]; then
git remote add upstream https://github.com/thoth-tech/arcade-games.git
git fetch upstream
echo "Compare upstream ${GITHUB_BASE_REF} with origin ${GITHUB_HEAD_REF}"
declare DIRECTORIES=($(git diff --name-only --merge-base upstream/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} games | awk -F'/' '{print "games/" $2 "/"}' | sort -u))
else
echo "Compare origin ${GITHUB_BASE_REF} with origin ${GITHUB_HEAD_REF}"
declare DIRECTORIES=($(git diff --name-only --merge-base origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} games | awk -F'/' '{print "games/" $2 "/"}' | sort -u))
fi
GAME_DIR=()
for dir in "${DIRECTORIES[@]}"
do
if [ $(expr length ${dir//[!\/]}) -eq 2 ]; then
GAME_DIR+=($dir)
else
echo skipping: $dir
fi
done
#echo "::set-output name=game-directory::${GAME_DIR[@]}"
echo game-directory=${GAME_DIR[@]} >> $GITHUB_OUTPUT
CSharpFound=false
NoCSharpFound=false
echo Games:
for dir in "${GAME_DIR[@]}"
do
echo "$dir"
if [ -f "$dir"*.csproj ]; then
CSharpFound=true #if any program has a .csproj file, set the variable to true
else
NoCSharpFound=true #if any program does not have a .csproj file, set the variable to true
fi
done
echo Games located: "${#GAME_DIR[@]}"
echo C# Found: $CSharpFound
echo No C# Found: $NoCSharpFound
echo CSharpFound=$CSharpFound >> $GITHUB_OUTPUT
echo NoCSharpFound=$NoCSharpFound >> $GITHUB_OUTPUT
echo Number-of-games=${#GAME_DIR[@]} >> $GITHUB_OUTPUT
compile-games-linux:
if: needs.get-game-directory.outputs.Number-of-games > 0
runs-on: ubuntu-latest
needs: get-game-directory
steps:
- name: Checkout feature branch
uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Update Packages
run: sudo apt-get update
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install SplashKit
run: |
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
- name: Add splashkit to path
run: echo "$HOME/.splashkit" >> $GITHUB_PATH
- name: Install dependencies, compile splashkit
run: |
skm linux install
- name: Compile Game
run: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
for dir in ${GAME_DIR[@]}
do
echo $dir
./compile-game.sh $GITHUB_WORKSPACE/$dir linux-x86
done
- uses: actions/upload-artifact@v3
with:
name: linux-programs
path: |
**/games/*/published/
# This can be used to debug the build, see https://github.com/lhotari/action-upterm
# Open the comile log for Linux, and copy the ssh connection. Note you need to have setup a public key for your SSh connection try ssh-keygen -t ed25519 if you get Permission denied (publickey)
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
compile-dotnet-games-arm:
if: needs.get-game-directory.outputs.CSharpFound == 'true' && needs.get-game-directory.outputs.Number-of-games > 0
runs-on: ubuntu-latest
needs: get-game-directory
steps:
- name: Checkout feature branch
uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Update Packages
run: sudo apt-get update
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install SplashKit
run: |
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
- name: Add splashkit to path
run: echo "$HOME/.splashkit" >> $GITHUB_PATH
- name: Install dependencies, compile splashkit
run: |
skm linux install
- name: Compile Game
run: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
GAME_DIR=($GAME_DIR)
for dir in ${GAME_DIR[@]}
do
echo "check " $dir
if [ -f "$dir"*.csproj ]; then
echo "Running for " $dir
./compile-game.sh $GITHUB_WORKSPACE/$dir linux-arm
fi
done
- uses: actions/upload-artifact@v3
with:
name: arm-programs
path: |
**/games/*/published/
compile-games-windows:
if: needs.get-game-directory.outputs.Number-of-games > 0
runs-on: windows-latest
needs: get-game-directory
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-cc
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Install SplashKit
run: |
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
- name: Compile Game
run: |
export PATH=$PATH:/home/runneradmin/.splashkit
export PATH=$PATH:/c/Program\ Files/dotnet
echo $PATH
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
for dir in ${GAME_DIR[@]}
do
./compile-game.sh $GITHUB_WORKSPACE/$dir win-x86
done
- uses: actions/upload-artifact@v3
with:
name: windows-programs
path: |
**/games/*/published/
compile-games-arm:
if: needs.get-game-directory.outputs.NoCSharpFound == 'true' && needs.get-game-directory.outputs.Number-of-games > 0
runs-on: ubuntu-latest
needs: get-game-directory
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Install Splashkit & Compile Game
uses: pguyot/arm-runner-action@v2
with:
cpu: cortex-a8
base_image: raspios_lite:latest
image_additional_mb: 4096
shell: bash
import_github_env: true
export_github_env: true
bind_mount_repository: true
commands: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
sudo apt-get update
sudo apt install --assume-yes git cmake
# curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel STS
# export PATH=$PATH:$HOME/.dotnet
# export DOTNET_ROOT=$HOME/.dotnet
# echo $PATH
# echo $DOTNET_ROOT
# dotnet --version
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
export PATH=$PATH:$HOME/.splashkit
sudo apt install --assume-yes libsdl2-dev libsdl2-gfx-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-net-dev libsdl2-image-dev libncurses-dev libpng-dev libcurl4-openssl-dev libbz2-dev libflac-dev libvorbis-dev libmikmod-dev libwebp-dev libfreetype6-dev
skm linux install
for dir in ${GAME_DIR[@]}
do
if [ ! -f "$dir"*.csproj ]; then
./compile-game.sh $dir linux-arm
fi
done
- uses: actions/upload-artifact@v3
with:
name: arm-programs
path: |
**/games/*/published/
push-games:
runs-on: ubuntu-latest
needs:
[
get-game-directory,
compile-games-linux,
compile-games-windows,
compile-games-arm,
compile-dotnet-games-arm,
]
if: |
always() &&
needs.compile-games-windows.result == 'success' &&
needs.compile-games-linux.result == 'success' &&
(needs.compile-games-arm.result == 'success' || needs.compile-games-arm.result == 'skipped') &&
(needs.compile-dotnet-games-arm.result == 'success' || needs.compile-dotnet-games-arm.result == 'skipped')
steps:
- name: Checkout feature branch
uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- uses: actions/download-artifact@v3
with:
name: windows-programs
path: ./windows-downloads
- uses: actions/download-artifact@v3
with:
name: linux-programs
path: ./linux-downloads
- uses: actions/download-artifact@v3
with:
name: arm-programs
path: ./arm-downloads
- name: Files downloaded
run: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
FOLDERS=("windows-downloads" "linux-downloads" "arm-downloads")
for dir in ${GAME_DIR[@]}
do
game_name=$(basename $dir)
cd $GITHUB_WORKSPACE/compiled-games
if [ ! -d "${game_name}" ]; then
mkdir ${game_name}
else
rm -rf ${game_name}/*
fi
cd ${game_name}
for folder in "${FOLDERS[@]}"
do
chmod 777 $GITHUB_WORKSPACE/$folder/games/${game_name}/*
cp $GITHUB_WORKSPACE/$folder/games/${game_name}/published/* .
done
done
- name: Git Add, Commit, Push
run: |
cd $GITHUB_WORKSPACE
git config user.name github-actions
git config user.email github-actions@github.com
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
for dir in ${GAME_DIR[@]}
do
game_name=$(basename $dir)
git add compiled-games/$game_name
done
git commit -m "Compiled Games"
git push origin HEAD:${GITHUB_HEAD_REF}
add-compiled-label:
needs: push-games
if: |
always() &&
needs.push-games.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Add label
uses: andymckay/labeler@master
with:
add-labels: "compiled"