-
Notifications
You must be signed in to change notification settings - Fork 1.1k
300 lines (298 loc) · 14 KB
/
windows.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
name: windows
on:
push:
branches:
- master
tags:
- '*'
pull_request: {}
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: true
matrix:
arch: [i686, x86_64, armv7, aarch64]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: false
- name: Set up environment for windows-latest
shell : bash
if: ${{ matrix.os == 'windows-latest' }}
run: |
echo "wget=C:\msys64\usr\bin\wget.exe" >> $GITHUB_ENV
echo "unzip=unzip" >> $GITHUB_ENV
if [ ${{ matrix.arch }} = "i686" ]; then
echo "cmake_arch=Win32" >> $GITHUB_ENV
elif [ ${{ matrix.arch }} = "x86_64" ]; then
echo "cmake_arch=x64" >> $GITHUB_ENV
elif [ ${{ matrix.arch }} = "armv7" ]; then
echo "cmake_arch=ARM" >> $GITHUB_ENV
else
echo "cmake_arch=ARM64" >> $GITHUB_ENV
fi
- name: Set up environment for ubuntu-latest
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
echo "wget=wget" >> $GITHUB_ENV
echo "unzip=unzip" >> $GITHUB_ENV
- name: Restore timestamps
run: |
${{ env.wget }} https://github.com/MestreLion/git-tools/archive/refs/heads/main.zip
${{ env.unzip }} main.zip
python git-tools-main/git-restore-mtime
- name: List build cache restore keys
shell : bash
run: |
# Look for the last 9 build caches (GitHub supports max 10 including current one)
for number in 1 2 3 4 5 6 7 8 9
do
id=$((${{ github.run_number }} - number))
echo "cache_$number=windows-${{ github.ref }}-${{ matrix.arch }}-${{ matrix.os }}-$id" >> $GITHUB_ENV
done
- name: Handle build cache
uses: actions/cache@v2
with:
path: |
build
key: windows-${{ github.ref }}-${{ matrix.arch }}-${{ matrix.os }}-${{ github.run_number }}
restore-keys: |
${{ env.cache_1 }}
${{ env.cache_2 }}
${{ env.cache_3 }}
${{ env.cache_4 }}
${{ env.cache_5 }}
${{ env.cache_6 }}
${{ env.cache_7 }}
${{ env.cache_8 }}
${{ env.cache_9 }}
- name: Download dependencies
run: |
${{ env.wget }} https://github.com/supertuxkart/dependencies/releases/download/preview/dependencies-win-${{ matrix.arch }}.zip
${{ env.unzip }} dependencies-win-${{ matrix.arch }}.zip
- name: Install MinGW for i686 or x86_64
if: ${{ matrix.os == 'ubuntu-latest' && ( matrix.arch == 'i686' || matrix.arch == 'x86_64' ) }}
run: |
cd /
sudo mkdir -p /data/mxe/usr
cd /data/mxe/usr
# It's compiled from https://github.com/mxe/mxe
sudo wget https://github.com/supertuxkart/dependencies/releases/download/preview/mxe_static_mingw.zip
sudo unzip mxe_static_mingw.zip
sudo rm mxe_static_mingw.zip
# For libfl.so.2
sudo apt install -y libfl-dev
- name: Install MinGW for armv7 or aarch64
if: ${{ matrix.os == 'ubuntu-latest' && ( matrix.arch == 'armv7' || matrix.arch == 'aarch64' ) }}
run: |
cd /
sudo wget https://github.com/mstorsjo/llvm-mingw/releases/download/20210423/llvm-mingw-20210423-msvcrt-ubuntu-18.04-x86_64.tar.xz
sudo tar xf llvm-mingw-20210423-msvcrt-ubuntu-18.04-x86_64.tar.xz
sudo mv llvm-mingw-20210423-msvcrt-ubuntu-18.04-x86_64 llvm-mingw
- name: Set up MinGW Toolchain for i686
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'i686' }}
run: |
echo "SET(CMAKE_SYSTEM_NAME Windows)" > toolchain.cmake
echo "SET(CMAKE_C_COMPILER /data/mxe/usr/bin/i686-w64-mingw32.static.posix.dw2-gcc)" >> toolchain.cmake
echo "SET(CMAKE_CXX_COMPILER /data/mxe/usr/bin/i686-w64-mingw32.static.posix.dw2-g++)" >> toolchain.cmake
echo "SET(CMAKE_RC_COMPILER /data/mxe/usr/bin/i686-w64-mingw32.static.posix.dw2-windres)" >> toolchain.cmake
echo "SET(CMAKE_FIND_ROOT_PATH \${PROJECT_SOURCE_DIR}/dependencies-win-i686 /data/mxe/usr/i686-w64-mingw32.static.posix.dw2/ /data/mxe/usr/lib/gcc/i686-w64-mingw32.static.posix.dw2/5.5.0/)" >> toolchain.cmake
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> toolchain.cmake
echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ALWAYS)" >> toolchain.cmake
echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> toolchain.cmake
- name: Set up MinGW Toolchain for x86_64
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' }}
run: |
echo "SET(CMAKE_SYSTEM_NAME Windows)" > toolchain.cmake
echo "SET(CMAKE_C_COMPILER /data/mxe/usr/bin/x86_64-w64-mingw32.static.posix.seh-gcc)" >> toolchain.cmake
echo "SET(CMAKE_CXX_COMPILER /data/mxe/usr/bin/x86_64-w64-mingw32.static.posix.seh-g++)" >> toolchain.cmake
echo "SET(CMAKE_RC_COMPILER /data/mxe/usr/bin/x86_64-w64-mingw32.static.posix.seh-windres)" >> toolchain.cmake
echo "SET(CMAKE_FIND_ROOT_PATH \${PROJECT_SOURCE_DIR}/dependencies-win-x86_64 /data/mxe/usr/x86_64-w64-mingw32.static.posix.seh/ /data/mxe/usr/lib/gcc/x86_64-w64-mingw32.static.posix.seh/5.5.0/)" >> toolchain.cmake
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> toolchain.cmake
echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ALWAYS)" >> toolchain.cmake
echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> toolchain.cmake
# Manually specify CMAKE_SYSTEM_PROCESSOR, it can only be set together with -DDCMAKE_SYSTEM_NAME
- name: Configure bulid for MSVC
if: ${{ matrix.os == 'windows-latest' }}
run: |
mkdir -Force build
cd build
cmake .. -G "Visual Studio 17 2022" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} -A ${{ env.cmake_arch }} -DCHECK_ASSETS=OFF
- name: Configure bulid for MinGW (i686 or x86_64)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch != 'armv7' && matrix.arch != 'aarch64' }}
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHECK_ASSETS=OFF -DUSE_DIRECTX=ON
- name: Configure bulid for MinGW (armv7 or aarch64)
if: ${{ matrix.os == 'ubuntu-latest' && ( matrix.arch == 'armv7' || matrix.arch == 'aarch64' ) }}
run: |
mkdir -p build
cd build
cmake .. -DLLVM_ARCH=${{ matrix.arch }} -DLLVM_PREFIX=/llvm-mingw -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-llvm-mingw.cmake -DCHECK_ASSETS=OFF -DUSE_DIRECTX=ON
- name: Build for MSVC
if: ${{ matrix.os == 'windows-latest' }}
working-directory: build
run: |
cmake --build . --config Debug
- name: Build for MinGW
if: ${{ matrix.os == 'ubuntu-latest' }}
working-directory: build
run: |
make -j4
cd ..
mv COPYING tools
- name: Upload binaries of MinGW
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}
path: build/bin/*
- name: Upload stk-code/data
# We only need to upload stk-code/data once
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'i686'}}
uses: actions/upload-artifact@v4
with:
name: data
path: data
- name: Upload stk-code/tools
# We only need to upload stk-code/tools once
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'i686'}}
uses: actions/upload-artifact@v4
with:
name: tools
path: tools
- name: Remove built binaries for less cache size
shell : bash
run: |
rm -rf build/Debug
rm -rf build/bin
packaging:
name: Packaging STK
needs: build
runs-on: windows-latest
steps:
- name: Configure packaging name for git master branch
shell : bash
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "release_tag=git`date +%Y%m%d`" >> $GITHUB_ENV
echo "release_name=preview" >> $GITHUB_ENV
- name: Configure packaging name for tag
shell : bash
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo "release_tag=`basename $GITHUB_REF`" >> $GITHUB_ENV
echo "release_name=`basename $GITHUB_REF`" >> $GITHUB_ENV
- name: Configure packaging name for non-releasing branch
shell : bash
if: ${{ (github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags/')) || github.repository_owner != 'supertuxkart' }}
run: |
echo "release_tag=" >> $GITHUB_ENV
echo "release_name=" >> $GITHUB_ENV
- name: Check for prerelease
shell : bash
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'rc') || contains(github.ref, 'beta') }}
run: |
echo "release_pre=true" >> $GITHUB_ENV
- name: Check for non-prerelease
shell : bash
if: ${{ github.ref != 'refs/heads/master' && !contains(github.ref, 'rc') && !contains(github.ref, 'beta') }}
run: |
echo "release_pre=false" >> $GITHUB_ENV
- name: Show packaging name
shell : bash
run : |
echo "${{ env.release_tag }}"
echo "${{ env.release_name }}"
echo "${{ env.release_pre }}"
- name: Download MinGW binaries and data
uses: actions/download-artifact@v4
- name: Generate .pdb files
if: ${{ env.release_tag != '' }}
run: |
C:\msys64\usr\bin\wget.exe https://github.com/rainers/cv2pdb/releases/download/v0.50/cv2pdb-0.50.zip
unzip cv2pdb-0.50.zip
cd i686
..\cv2pdb.exe supertuxkart.exe
cd ..
cd x86_64
..\cv2pdb.exe supertuxkart.exe
- name: Downloading stk-assets
if: ${{ env.release_tag != '' }}
run: |
C:\msys64\usr\bin\wget.exe https://github.com/supertuxkart/stk-assets-mobile/releases/download/git/stk-assets-full.zip
mkdir stk-assets
cd stk-assets
unzip ..\stk-assets-full.zip
- name: Move folders
shell : bash
if: ${{ env.release_tag != '' }}
run: |
mkdir SuperTuxKart-${{ env.release_tag }}-win
mv stk-assets SuperTuxKart-${{ env.release_tag }}-win
mkdir SuperTuxKart-${{ env.release_tag }}-win/stk-code
mv data SuperTuxKart-${{ env.release_tag }}-win/stk-code
mv tools/run_game.bat SuperTuxKart-${{ env.release_tag }}-win
mkdir SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-i686
mkdir SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-x86_64
mkdir SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-armv7
mkdir SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-aarch64
mv i686 SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-i686/bin
mv x86_64 SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-x86_64/bin
mv armv7 SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-armv7/bin
mv aarch64 SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-aarch64/bin
# libwinpthread-1.dll is useless because we statically link
rm -f SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-armv7/bin/libwinpthread-1.dll
rm -f SuperTuxKart-${{ env.release_tag }}-win/stk-code/build-aarch64/bin/libwinpthread-1.dll
- name: Start packaging STK
if: ${{ env.release_tag != '' }}
run: |
Compress-Archive -LiteralPath SuperTuxKart-${{ env.release_tag }}-win -DestinationPath SuperTuxKart-${{ env.release_tag }}-win.zip
- name: Configure NSIS script
shell : bash
if: ${{ env.release_tag != '' && startsWith(github.ref, 'refs/tags/') }}
run: |
mv tools SuperTuxKart-${{ env.release_tag }}-win/stk-code
cd SuperTuxKart-${{ env.release_tag }}-win/stk-code/tools/windows_installer
for arch in i686 x86_64 aarch64
do
cp supertuxkart-github-actions.nsi $arch.nsi
sed -i "s/define APPNAMEANDVERSION \"\"/define APPNAMEANDVERSION \"SuperTuxKart ${{ env.release_tag }}\"/g" $arch.nsi
sed -i "s/define ARCH \"\"/define ARCH \"$arch\"/g" $arch.nsi
sed -i "s/define VERSION \"\"/define VERSION \"${{ env.release_tag }}\"/g" $arch.nsi
sed -i "s/OutFile \"\"/OutFile \"SuperTuxKart-${{ env.release_tag }}-installer-$arch.exe\"/g" $arch.nsi
for filename in $(ls ../../build-$arch/bin)
do
file="\\\\$filename"
sed -i "288a\ DELETE /REBOOTOK \"\$INSTDIR$file\"" $arch.nsi
done
# Print result
#cat $arch.nsi
done
mv ../COPYING ../..
- name: Run makensis.exe
if: ${{ env.release_tag != '' && startsWith(github.ref, 'refs/tags/') }}
run: |
cd SuperTuxKart-${{ env.release_tag }}-win\stk-code\tools\windows_installer
C:\msys64\usr\bin\wget.exe https://nsis.sourceforge.io/mediawiki/images/6/6c/Shelllink.zip
unzip Shelllink.zip
Move-Item Unicode\Plugins\ShellLink.dll .
& "C:\Program Files (x86)\NSIS\makensis.exe" i686.nsi
& "C:\Program Files (x86)\NSIS\makensis.exe" x86_64.nsi
& "C:\Program Files (x86)\NSIS\makensis.exe" aarch64.nsi
- name: Create release
uses: ncipollo/[email protected]
if: ${{ env.release_tag != '' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "SuperTuxKart-*.zip, SuperTuxKart-${{ env.release_tag }}-win/stk-code/tools/windows_installer/*.exe"
tag: ${{ env.release_name }}
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
allowUpdates: true
prerelease: ${{ env.release_pre }}