-
Notifications
You must be signed in to change notification settings - Fork 62
288 lines (249 loc) · 7.4 KB
/
build.yml
File metadata and controls
288 lines (249 loc) · 7.4 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
# .github/workflows/build.yml
on:
push:
tags:
- "20[0-9][0-9][0-1][0-9][0-3][0-9]"
- "20[0-9][0-9][0-1][0-9][0-3][0-9].*"
branches:
- "**"
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
build-windows:
runs-on: windows-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup MSYS2 (MINGW64)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
release: true
update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-make
mingw-w64-x86_64-binutils
mingw-w64-x86_64-ntldd
wget
unzip
tar
p7zip
- name: Download FFmpeg
shell: msys2 {0}
run: |
set -euxo pipefail
./download_and_extract_windows_deps.sh ffmpeg
- name: Download SDL2
shell: msys2 {0}
run: |
set -euxo pipefail
./download_and_extract_windows_deps.sh sdl2 release-2.32.10
- name: Download SDL2_ttf
shell: msys2 {0}
run: |
set -euxo pipefail
./download_and_extract_windows_deps.sh sdl2_ttf release-2.24.0
- name: Build
shell: msys2 {0}
run: |
set -euxo pipefail
mingw32-make -j$(nproc)
- name: Copy runtime DLLs
shell: msys2 {0}
run: |
set -euxo pipefail
ntldd -R video-compare.exe | \
awk '/mingw64/ {print $1}' | \
sort -u | \
while read dll; do
cp -f "/mingw64/bin/$dll" .
done
- name: Verify build output
shell: powershell
run: |
if (Test-Path "video-compare.exe") {
$file = Get-Item "video-compare.exe"
Write-Host "Build successful!"
Write-Host "File: $($file.Name)"
Write-Host "Size: $([math]::Round($file.Length / 1MB, 2)) MB"
Write-Host "Date: $($file.LastWriteTime)"
} else {
Write-Error "Build failed: video-compare.exe not found"
exit 1
}
- name: Strip executable
shell: msys2 {0}
run: |
set -euxo pipefail
strip video-compare.exe
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: video-compare-windows
path: |
video-compare.exe
*.dll
README.md
retention-days: 90
release-windows:
if: startsWith(github.ref, 'refs/tags/')
needs: build-windows
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
env:
ZIP_NAME: video-compare-${{ github.ref_name }}-win10-x86_64.zip
steps:
- name: Download Windows build artifacts
uses: actions/download-artifact@v8
with:
name: video-compare-windows
- name: Package Windows release
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y zip
mkdir -p release
cp -f video-compare.exe README.md release/
# Copy all DLLs (if any) from the Windows artifact bundle.
shopt -s nullglob
dlls=( *.dll )
if [ "${#dlls[@]}" -gt 0 ]; then
cp -f *.dll release/
fi
rm -f "$ZIP_NAME"
(cd release && zip -r "../$ZIP_NAME" .)
echo "Created $ZIP_NAME"
ls -lh "$ZIP_NAME"
- name: Generate artifact attestation (Windows zip)
uses: actions/attest-build-provenance@v3
with:
subject-path: ${{ env.ZIP_NAME }}
- name: Install Syft (SBOM generator)
shell: bash
run: |
set -euo pipefail
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sudo sh -s -- -b /usr/local/bin
syft version
- name: Generate SBOM (SPDX JSON)
shell: bash
run: |
set -euo pipefail
syft dir:release -o spdx-json=sbom.spdx.json
ls -lh sbom.spdx.json
- name: Generate SBOM attestation (Windows zip)
uses: actions/attest-sbom@v2
with:
subject-path: ${{ env.ZIP_NAME }}
sbom-path: sbom.spdx.json
- name: Create draft GitHub Release (if missing)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
repo="${GITHUB_REPOSITORY}"
if ! gh release view "$tag" -R "$repo" >/dev/null 2>&1; then
gh release create "$tag" -R "$repo" --draft --title "$tag" --notes "Release $tag"
else
echo "Release $tag already exists"
fi
- name: Upload Windows zip to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
repo="${GITHUB_REPOSITORY}"
gh release upload "$tag" -R "$repo" "$ZIP_NAME" --clobber=false
gh release upload "$tag" -R "$repo" sbom.spdx.json --clobber=false
build-linux:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libavformat-dev \
libavcodec-dev \
libavfilter-dev \
libavutil-dev \
libswscale-dev \
libswresample-dev \
libsdl2-dev \
libsdl2-ttf-dev
- name: Build
run: make -j$(nproc)
- name: Verify build output
run: |
if [ -f "video-compare" ]; then
echo "Build successful!"
ls -lh video-compare
file video-compare
else
echo "Build failed: video-compare not found"
exit 1
fi
- name: Strip executable
run: |
strip video-compare
echo "Stripped executable. New size:"
ls -lh video-compare
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: video-compare-linux
path: |
video-compare
README.md
retention-days: 90
build-macos:
runs-on: macos-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install dependencies via Homebrew
run: |
brew install ffmpeg sdl2 sdl2_ttf
- name: Build
run: make -j$(nproc)
- name: Verify build output
run: |
if [ -f "video-compare" ]; then
echo "Build successful!"
ls -lh video-compare
file video-compare
else
echo "Build failed: video-compare not found"
exit 1
fi
- name: Strip executable
run: |
strip video-compare
echo "Stripped executable. New size:"
ls -lh video-compare
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: video-compare-macos
path: |
video-compare
README.md
retention-days: 90