-
Notifications
You must be signed in to change notification settings - Fork 1
367 lines (313 loc) · 12.1 KB
/
Build.yml
File metadata and controls
367 lines (313 loc) · 12.1 KB
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
name: Build
on:
workflow_dispatch:
push:
branches:
- "**"
pull_request:
branches: [ "main" ]
jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- id: win-msvc
name: Windows MSVC
os: windows-latest
cmake-platform-args: -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -G "Visual Studio 17 2022"
- id: win-llvm
name: Windows LLVM
os: windows-latest
cmake-platform-args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja
- id: mac
name: MacOS
os: macos-latest
cmake-platform-args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja
- id: linux
name: Linux
os: ubuntu-latest
cmake-platform-args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v4
- name: Install Latest LLVM on Windows
if: matrix.config.id == 'win-llvm'
run: |
Invoke-WebRequest -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.7/LLVM-20.1.7-win64.exe" -OutFile llvm.exe
7z x llvm.exe -o"C:\Program Files\Latest LLVM"
echo "C:\Program Files\Latest LLVM\bin" >> $env:GITHUB_PATH
- name: Install Linux dependencies
if: matrix.config.id == 'linux'
run: sudo apt-get install -y libx11-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev
- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build ${{ matrix.config.cmake-platform-args }} -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
- name: Build
run: |
cmake --build ${{ github.workspace }}/build --config Release
- name: Upload
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.config.id }}
path: ${{ github.workspace }}/bin/*
build-relwithdebinfo:
strategy:
fail-fast: false
matrix:
config:
- id: win-msvc
name: Windows MSVC
os: windows-latest
cmake-platform-args: -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -G "Visual Studio 17 2022"
- id: win-llvm
name: Windows LLVM
os: windows-latest
cmake-platform-args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja
- id: mac
name: MacOS
os: macos-latest
cmake-platform-args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja
- id: linux
name: Linux
os: ubuntu-latest
cmake-platform-args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja
name: Build ${{ matrix.config.name }} RelWithDebInfo
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v4
- name: Install Latest LLVM on Windows
if: matrix.config.name == 'Windows LLVM'
run: |
Invoke-WebRequest -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.7/LLVM-20.1.7-win64.exe" -OutFile llvm.exe
7z x llvm.exe -o"C:\Program Files\Latest LLVM"
echo "C:\Program Files\Latest LLVM\bin" >> $env:GITHUB_PATH
- name: Install Linux dependencies
if: matrix.config.name == 'Linux'
run: sudo apt-get install -y libx11-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev
- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build ${{ matrix.config.cmake-platform-args }} -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: Build
run: cmake --build ${{ github.workspace }}/build --config RelWithDebInfo
- name: Upload
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.config.id }}-relwithdebinfo
path: ${{ github.workspace }}/bin/*
win-msi:
name: Build Windows installer
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install WiX toolset
run: |
curl.exe -LO https://github.com/wixtoolset/wix/releases/download/v6.0.1/wix-cli-x64.msi
msiexec /i wix-cli-x64.msi /quiet
- name: Download zip
uses: actions/download-artifact@v4
with:
name: build-win-msvc
path: ${{ github.ref_name }}
- name: Build installer
id: build
run: |
$packageName = "${{ github.ref_name }}"
$version = "1.0.0"
powershell -ExecutionPolicy Bypass -File .\.github\scripts\build-msi.ps1 `
-SourceDir .\$packageName `
-AppName "$packageName" `
-Manufacturer "Johnny Cena" `
-Version "$version" `
-OutputMsi "$packageName-$version.msi"
echo "installer-path=$packageName-$version.msi" >> $env:GITHUB_OUTPUT
- name: Test installer
id: test
run: |
$proc = Start-Process -FilePath msiexec.exe `
-ArgumentList '/i "${{ steps.build.outputs.installer-path }}" /norestart /quiet' `
-PassThru
$proc.WaitForExit(30000)
dir "C:\Program Files\${{ github.ref_name }}"
- name: Upload installer
uses: actions/upload-artifact@v4
with:
path: ${{ steps.build.outputs.installer-path }}
name: Windows installer
linux-deb:
name: Build Debian package
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build output
uses: actions/download-artifact@v4
with:
name: build-linux
path: ${{ github.workspace }}
- name: Build
id: build
run: |
sudo apt-get update && sudo apt-get install -y libopengl0 libglu1-mesa
PACKAGE_NAME=${{ github.ref_name }}
chmod +x ./$PACKAGE_NAME
PACKAGE_VERSION=$(./$PACKAGE_NAME --version --minimal-output)
PACKAGE_DESC="$(./$PACKAGE_NAME --desc --minimal-output)"
PACKAGE_DIR="./$PACKAGE_NAME-$PACKAGE_VERSION"
mkdir -p "$PACKAGE_DIR"/usr/bin
mv "./$PACKAGE_NAME" "$PACKAGE_DIR/usr/bin/"
ln -sf libraylib.so.5.5.0 libraylib.so.550
ln -sf libraylib.so.5.5.0 libraylib.so
mkdir -p "$PACKAGE_DIR"/usr/lib/$PACKAGE_NAME
mv ./*.so* "$PACKAGE_DIR/usr/lib/$PACKAGE_NAME/"
mkdir -p "$PACKAGE_DIR/usr/share/$PACKAGE_NAME/"
cp -r ./resources "$PACKAGE_DIR/usr/share/$PACKAGE_NAME/"
ICON_DIR="usr/share/icons"
mkdir -p "$PACKAGE_DIR/$ICON_DIR"
ICON_PATH="$ICON_DIR/$PACKAGE_NAME.png"
cp ./resources/icon.png "$PACKAGE_DIR/$ICON_PATH"
DESKTOP_ICON_LINE="Icon=/$ICON_PATH"
rm -rf resources
mkdir -p "$PACKAGE_DIR/usr/share/applications/"
cat <<EOF > "$PACKAGE_DIR/usr/share/applications/$PACKAGE_NAME.desktop"
[Desktop Entry]
Version=1.0
Name=$PACKAGE_NAME
GenericName=$PACKAGE_NAME
$DESKTOP_ICON_LINE
Comment=$PACKAGE_DESC
Exec=/usr/bin/$PACKAGE_NAME
TryExec=/usr/bin/$PACKAGE_NAME
Terminal=false
Type=Application
Categories=Utility;Game;
Keywords=Game;Snake;Raylib;C;CPP;
EOF
mkdir -p $PACKAGE_DIR/DEBIAN
cat <<EOF > "$PACKAGE_DIR/DEBIAN/control"
Package: $PACKAGE_NAME
Version: $PACKAGE_VERSION
Section: utils
Depends: libc6, libopengl0, libglx0, libglu1-mesa, libstdc++6, libgcc-s1, libx11-6, libxcb1
Priority: optional
Architecture: amd64
Maintainer: Johnny Cena <iamahuman1395@gmail.com>
Description: $PACKAGE_DESC
EOF
dpkg-deb --build "$PACKAGE_DIR" "$PACKAGE_DIR".deb
echo "package-path=$PACKAGE_DIR.deb" >> $GITHUB_OUTPUT
- name: Test package
run: |
sudo dpkg -i ${{ steps.build.outputs.package-path }}
- name: Upload
uses: actions/upload-artifact@v4
with:
path: ${{ steps.build.outputs.package-path }}
name: Debian package
cleanup:
name: Cleanup
runs-on: ubuntu-latest
needs: [ linux-deb, win-msi, build-relwithdebinfo ]
permissions:
contents: write
steps:
- name: Download build outputs
uses: actions/download-artifact@v4
- name: Organize
id: organize
run: |
rm -rf "Debian package" "Windows installer"
mv build-win-msvc/resources .
rm -rf */resources
mkdir Release
mkdir RelWithDebInfo
mv build-*-relwithdebinfo RelWithDebInfo/
cd RelWithDebInfo
cd build-win-msvc-relwithdebinfo && zip -r ../Windows-MSVC.zip * && cd ..
cd build-win-llvm-relwithdebinfo && zip -r ../Windows-LLVM.zip * && cd ..
cd build-mac-relwithdebinfo && zip -r ../MacOS.zip * && cd ..
cd build-linux-relwithdebinfo && zip -r ../Linux.zip * && cd ..
cd ..
mv build-* Release
cd Release
cd build-win-msvc && zip -r ../Windows-MSVC.zip * && cd ..
cd build-win-llvm && zip -r ../Windows-LLVM.zip * && cd ..
cd build-mac && zip -r ../MacOS.zip * && cd ..
cd build-linux && zip -r ../Linux.zip * && cd ..
cd ..
- name: Upload Release zip
uses: actions/upload-artifact@v4
with:
path: Release/*.zip
name: Release Builds
- name: Upload RelWithDebInfo zip
uses: actions/upload-artifact@v4
with:
path: RelWithDebInfo/*.zip
name: RelWithDebInfo Builds
- name: Upload resources zip
uses: actions/upload-artifact@v4
with:
path: resources/*
name: resources
- name: Delete old artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: build-*
publish:
name: Publish
if: github.ref_name != 'Template'
permissions:
contents: write
needs: cleanup
runs-on: ubuntu-latest
steps:
- name: Download Windows installer
uses: actions/download-artifact@v4
with:
name: Windows installer
- name: Download Debian package
uses: actions/download-artifact@v4
with:
name: Debian package
- name: Download zips
uses: actions/download-artifact@v4
with:
name: Release Builds
- name: Prepare
run: |
mv Windows-MSVC.zip Windows.zip
rm Windows-LLVM.zip
unzip MacOS.zip -d mac
rm MacOS.zip
cd mac
ln -sf libraylib.dylib.5.5.0 libraylib.550.dylib
ln -sf libraylib.dylib.5.5.0 libraylib.dylib
tar -czvf ../MacOS.tar.gz *
cd ..
unzip Linux.zip -d linux
rm Linux.zip
cd linux
ln -sf libraylib.so.5.5.0 libraylib.so.550
ln -sf libraylib.so.5.5.0 libraylib.so
tar -czvf ../Linux.tar.gz *
- name: Delete tag
uses: dev-drprasad/delete-tag-and-release@v1.1
with:
tag_name: nightly-${{ github.ref_name }}
delete_release: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: nightly-${{ github.ref_name }}
name: Development build for ${{ github.ref_name }}
body: |
Build triggered by commit ${{ github.sha }} on branch ${{ github.ref_name }}.
This is a build of the **latest commit**, it is not guaranteed to be stable.
draft: false
prerelease: true
files: |
*.msi
*.deb
*.zip
*.tar.gz