-
Notifications
You must be signed in to change notification settings - Fork 3
320 lines (260 loc) · 9.08 KB
/
build.yml
File metadata and controls
320 lines (260 loc) · 9.08 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
name: '🏦 Build'
env:
VERSION: 0.0.0
PACKAGE_SUFFIX: '-pre.45'
# PACKAGE_SUFFIX: ''
ASM_VERSION: 0.0.0
BUILD_TYPE: Release
VCPKG_HASH: f8be6942c0c5abd48bb325726d57af9ac39e251d
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
# builds native binary for all supported OSes
build-native:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
name: Windows x64
arch: x64
vcpkg_triplet: x64-windows-static
vcpkg_config: Release
dotnet_rid: win-x64
- os: ubuntu-latest
name: Linux x64
arch: x64
vcpkg_triplet: x64-linux
vcpkg_config: MinSizeRel
dotnet_rid: linux-x64
fail-fast: false
name: 'build: ${{ matrix.name }}'
env:
VCPKG_DEFAULT_VCPKG_TRIPLET: ${{ matrix.vcpkg_triplet }}
VCPKG_TRIPLET: ${{ matrix.vcpkg_triplet }}
VCPKG_CONFIG: ${{ matrix.vcpkg_config }}
DOTNET_RID: ${{ matrix.dotnet_rid }}
CMAKE_OPTIONS: ${{ matrix.cmake_options }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Linux GLFW depdendencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get --yes install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config
- uses: friendlyanon/setup-vcpkg@v1
# seems like the absense of commit hash expects vcpkg submodule, i don't want that
with:
committish: ${{ env.VCPKG_HASH }}
# set to false to clear any cache in case of build errors
cache: false
- name: configure
run: cmake -B build -S . -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -D "VCPKG_TARGET_TRIPLET=${{ env.VCPKG_TRIPLET }}" ${{ env.CMAKE_OPTIONS }}
working-directory: .
- name: build
run: cmake --build build --config ${{ env.VCPKG_CONFIG }}
working-directory: .
- name: debug
run: ls -R
working-directory: .
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: native-${{ matrix.dotnet_rid }}
path: |
xbin/**/*
if-no-files-found: error
# create a unified fat native binary
make-fat-native:
runs-on: ubuntu-latest
needs: build-native
name: '🎡 fat artifact'
steps:
- uses: actions/download-artifact@v4
with:
pattern: native-*
path: xbin/
merge-multiple: true
- name: debug
run: ls -R
working-directory: .
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: native-fat
compression-level: 9
if-no-files-found: error
path: |
xbin/**/*
build-managed:
needs: make-fat-native
runs-on: ubuntu-latest
name: 'Build managed + nuget'
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: native-fat
path: xbin/
- name: debug
run: ls -R
working-directory: .
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.0.x
- name: Build
run: dotnet build dotnet/Grey.sln -c release /p:Version=${{ env.VERSION }}${{ env.PACKAGE_SUFFIX }} /p:FileVersion=$VERSION /p:AssemblyVersion=$ASM_VERSION
- name: version
run: echo $VERSION >> docs/version.txt
- name: 🔢 prep release notes
run: |
grep -m 2 -B 1000 '^## ' docs/release-notes.md | tail -n +3 | head -n -2 > docs/version-notes.md
cat docs/version-notes.md
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: dotnet
compression-level: 9
if-no-files-found: error
path: |
dotnet/Grey/bin/Release/**/*nupkg
docs/release-notes.md
docs/version-notes.md
docs/version.txt
build-demo-apps:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
name: Windows x64
arch: x64
vcpkg_triplet: x64-windows-static
vcpkg_config: Release
dotnet_rid: win-x64
- os: ubuntu-latest
name: Linux x64
arch: x64
vcpkg_triplet: x64-linux
vcpkg_config: MinSizeRel
dotnet_rid: linux-x64
fail-fast: false
name: 'demo app: ${{ matrix.name }}'
needs:
- make-fat-native
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: native-fat
path: xbin/
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.0.x
- name: Publish
run: dotnet publish dotnet/ConsoleDemo/ -r ${{ matrix.dotnet_rid }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Setup screenshot tools (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb scrot mesa-utils libgl1-mesa-dri libegl1 libglu1-mesa xterm
- name: Run app and capture screenshot (Linux)
if: runner.os == 'Linux'
run: |
# Start Xvfb with GLX extension
Xvfb :99 -screen 0 1920x1080x24 +extension GLX +render -noreset &
export DISPLAY=:99
# Use software rendering
export LIBGL_ALWAYS_SOFTWARE=1
export MESA_GL_VERSION_OVERRIDE=3.3
# Wait for Xvfb to be ready
sleep 2
# Verify display is working
glxinfo | head -20 || echo "GLX not available"
# Start xterm (optional, for debugging)
xterm &
# Run the app in background
chmod +x dotnet/ConsoleDemo/bin/Release/net10.0/${{ matrix.dotnet_rid }}/publish/ConsoleDemo
dotnet/ConsoleDemo/bin/Release/net10.0/${{ matrix.dotnet_rid }}/publish/ConsoleDemo 2>&1 | tee app.log &
APP_PID=$!
# Wait for app to render
sleep 5
# Capture screenshot
mkdir -p screenshots
scrot screenshots/demo-${{ matrix.dotnet_rid }}.png
# Show app logs
cat app.log || true
# Kill the app
kill $APP_PID || true
- name: Run app and capture screenshot (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Start the app in background
$app = Start-Process -FilePath "dotnet\ConsoleDemo\bin\Release\net10.0\${{ matrix.dotnet_rid }}\publish\ConsoleDemo.exe" -PassThru
# Wait for app to render
Start-Sleep -Seconds 5
# Capture screenshot using PowerShell
New-Item -ItemType Directory -Force -Path screenshots
Add-Type -AssemblyName System.Windows.Forms,System.Drawing
$screens = [System.Windows.Forms.Screen]::AllScreens
$bounds = $screens[0].Bounds
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
$graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
$bitmap.Save("screenshots\demo-${{ matrix.dotnet_rid }}.png", [System.Drawing.Imaging.ImageFormat]::Png)
$graphics.Dispose()
$bitmap.Dispose()
# Kill the app
Stop-Process -Id $app.Id -Force -ErrorAction SilentlyContinue
- name: Flatten files for artifact upload
shell: bash
run: |
mkdir -p flat-output
# Copy published binaries
find dotnet/ConsoleDemo/bin/Release/net10.0/${{ matrix.dotnet_rid }}/publish/ -type f -exec cp {} flat-output/ \;
# Copy screenshots if they exist
find screenshots/ -type f -exec cp {} flat-output/ \; 2>/dev/null || true
ls -la flat-output/
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: dotnet-demo-${{ matrix.dotnet_rid }}
compression-level: 9
if-no-files-found: error
path: flat-output/
release:
name: '🕋 Release library'
runs-on: ubuntu-latest
needs:
- build-managed
if: github.ref == 'refs/heads/master'
steps:
- name: ⬇️ Download Library binaries
uses: actions/download-artifact@v4
with:
name: dotnet
path: dotnet
- name: debug
run: ls -R
working-directory: .
- name: print release notes
run: cat dotnet/docs/release-notes.md
- name: 📦 Publish to NuGet
run: dotnet nuget push dotnet/dotnet/Grey/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate