-
Notifications
You must be signed in to change notification settings - Fork 30
466 lines (427 loc) · 16.5 KB
/
build-main-on-push.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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
name: Snapshot Build
on:
push:
tags:
- 'r[0-9]+' # any tag name that looks like an svn commit
concurrency:
group: Snapshot Build
cancel-in-progress: true
jobs:
cleanup_previous_builds: # Delete unfinished draft prereleases, and prereleases older than 30 days (but keep at least 10)
name: Cleanup Previous Builds
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
// Get a list of all releases, sorted newest first
let releases =
(await github.paginate(
github.rest.repos.listReleases,
{
owner: context.repo.owner,
repo: context.repo.repo
}))
.sort((a,b) => b.created_at.localeCompare(a.created_at));
let releaseCount = 0;
let releasesToDelete = [];
// Initiate deletion of draft prereleases
for (const release of releases)
{
// Only cleanup prereleases
if (!release.prerelease)
continue;
// Failed builds leave drafts - delete them
if (release.draft)
{
console.log("Will delete draft prerelease: " + release.tag_name);
releasesToDelete.push(release.id);
continue;
}
// Keep at least 10, no matter how old
if (++releaseCount <= 10)
continue;
// We have more than 10 releases - delete those more than 30 days old
let daysAgo = Math.floor((new Date() - Date.parse(release.created_at)) / 1000 / 60 / 60 / 24);
if (daysAgo <= 30)
continue;
console.log("Will delete old prerelease: " + release.tag_name);
releasesToDelete.push(release.id);
}
if (releasesToDelete.length)
{
let promises = [];
for (const id of releasesToDelete)
{
promises.push(
github.rest.repos.deleteRelease(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: id
}));
}
console.log("Waiting for deletions to complete");
await Promise.all(promises);
}
console.log("Done.");
create_release:
name: Create Draft Release
needs: cleanup_previous_builds
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.release_id }}
steps:
- uses: actions/github-script@v6
id: create_release
env:
TAG_NAME: ${{ github.ref }}
RELEASE_NAME: ${{ github.ref }} snapshot
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
const { TAG_NAME, RELEASE_NAME } = process.env;
const createReleaseResponse = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: TAG_NAME.replace('refs/tags/', ''),
name: RELEASE_NAME.replace('refs/tags/', ''),
draft: true,
prerelease: true,
target_commitish: context.sha
});
core.setOutput('release_id', createReleaseResponse.data.id);
core.setOutput('upload_url', createReleaseResponse.data.upload_url);
build_doc:
name: Style check, Test Headless, Build Documentation
needs: create_release
runs-on: ubuntu-latest
steps:
- shell: bash
run: git config --global core.autocrlf input
- name: Checkout Source
uses: actions/checkout@v3
- name: Install Dependencies
shell: bash
run: |
sudo apt update
sudo apt-get -y install autoconf automake build-essential byacc flex xa65 dos2unix
sudo apt-get -y install texinfo texlive-fonts-recommended texlive-latex-extra libpcap-dev
- name: Build
id: build
shell: bash
run: |
cd vice
./src/buildtools/genvicedate_h.sh
./autogen.sh
./configure --enable-headlessui --enable-pdf-docs --enable-html-docs --without-pulse --without-alsa --without-png
make stylecheck
make
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: vice-pdf
path: vice/doc/vice.pdf
retention-days: 1
- name: Upload Release Asset
uses: actions/github-script@v6
env:
UPLOAD_URL: ${{ needs.create_release.outputs.upload_url }}
ASSET_PATH: vice/doc/vice.pdf
ASSET_NAME: vice.pdf
ASSET_CONTENT_TYPE: application/pdf
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
const fs = require('fs');
const { UPLOAD_URL, ASSET_PATH, ASSET_NAME, ASSET_CONTENT_TYPE } = process.env;
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
url: UPLOAD_URL,
headers: {
'content-type': ASSET_CONTENT_TYPE,
'content-length': fs.statSync(ASSET_PATH).size
},
name: ASSET_NAME,
data: fs.readFileSync(ASSET_PATH)
});
build:
name: Build
needs: [create_release, build_doc]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch:
- { msystem: MINGW64, arch: x86_64 }
- { msystem: MINGW32, arch: i686 }
ui: [ GTK3, SDL2, SDL1 ]
steps:
- run: git config --global core.autocrlf input
shell: bash
- name: Checkout Source
uses: actions/checkout@v3
- name: Download Documentation
uses: actions/download-artifact@v3
with:
name: vice-pdf
path: vice/doc/
- name: Install GTK3 Dependencies if Applicable
if: ${{ matrix.ui == 'GTK3' }}
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.arch.msystem }}
update: true
install: >-
git
base-devel
autotools
mingw-w64-${{ matrix.arch.arch }}-toolchain
unzip
zip
p7zip
subversion
mingw-w64-${{ matrix.arch.arch }}-pkg-config
mingw-w64-${{ matrix.arch.arch }}-ntldd
mingw-w64-${{ matrix.arch.arch }}-glew
mingw-w64-${{ matrix.arch.arch }}-giflib
mingw-w64-${{ matrix.arch.arch }}-lame
mingw-w64-${{ matrix.arch.arch }}-libvorbis
mingw-w64-${{ matrix.arch.arch }}-flac
mingw-w64-${{ matrix.arch.arch }}-icoutils
mingw-w64-${{ matrix.arch.arch }}-libpcap
mingw-w64-${{ matrix.arch.arch }}-libusb
mingw-w64-${{ matrix.arch.arch }}-curl
mingw-w64-${{ matrix.arch.arch }}-gtk3
mingw-w64-${{ matrix.arch.arch }}-xa65
- name: Install SDL2 Dependencies if Applicable
if: ${{ matrix.ui == 'SDL2' }}
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.arch.msystem }}
update: true
install: >-
git
base-devel
autotools
mingw-w64-${{ matrix.arch.arch }}-toolchain
unzip
zip
p7zip
subversion
mingw-w64-${{ matrix.arch.arch }}-pkg-config
mingw-w64-${{ matrix.arch.arch }}-ntldd
mingw-w64-${{ matrix.arch.arch }}-glew
mingw-w64-${{ matrix.arch.arch }}-giflib
mingw-w64-${{ matrix.arch.arch }}-lame
mingw-w64-${{ matrix.arch.arch }}-libvorbis
mingw-w64-${{ matrix.arch.arch }}-flac
mingw-w64-${{ matrix.arch.arch }}-icoutils
mingw-w64-${{ matrix.arch.arch }}-libpcap
mingw-w64-${{ matrix.arch.arch }}-libusb
mingw-w64-${{ matrix.arch.arch }}-curl
mingw-w64-${{ matrix.arch.arch }}-SDL2
mingw-w64-${{ matrix.arch.arch }}-SDL2_image
mingw-w64-${{ matrix.arch.arch }}-xa65
- name: Install SDL1 Dependencies if Applicable
if: ${{ matrix.ui == 'SDL1' }}
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.arch.msystem }}
update: true
install: >-
git
base-devel
autotools
mingw-w64-${{ matrix.arch.arch }}-toolchain
unzip
zip
p7zip
subversion
mingw-w64-${{ matrix.arch.arch }}-pkg-config
mingw-w64-${{ matrix.arch.arch }}-ntldd
mingw-w64-${{ matrix.arch.arch }}-glew
mingw-w64-${{ matrix.arch.arch }}-giflib
mingw-w64-${{ matrix.arch.arch }}-lame
mingw-w64-${{ matrix.arch.arch }}-libvorbis
mingw-w64-${{ matrix.arch.arch }}-flac
mingw-w64-${{ matrix.arch.arch }}-icoutils
mingw-w64-${{ matrix.arch.arch }}-libpcap
mingw-w64-${{ matrix.arch.arch }}-libusb
mingw-w64-${{ matrix.arch.arch }}-curl
mingw-w64-${{ matrix.arch.arch }}-SDL
mingw-w64-${{ matrix.arch.arch }}-SDL_image
mingw-w64-${{ matrix.arch.arch }}-xa65
- name: Build
id: build
shell: msys2 {0}
run: |
MINGW_INSTALLS=${{ matrix.arch.msystem }} ./vice/build/github-actions/build-msys2.sh ${{ matrix.ui }} "$(echo "${{ github.ref }}" | sed 's,.*/,,')"
echo "zip_path=$(cygpath -w -a vice/*.zip)" >> $GITHUB_OUTPUT
echo "zip_name=$(basename vice/*.zip)" >> $GITHUB_OUTPUT
echo "seven_zip_path=$(cygpath -w -a vice/*.7z)" >> $GITHUB_OUTPUT
echo "seven_zip_name=$(basename vice/*.7z)" >> $GITHUB_OUTPUT
- name: Upload Zip
id: upload-zip
uses: actions/github-script@v6
env:
UPLOAD_URL: ${{ needs.create_release.outputs.upload_url }}
ASSET_PATH: ${{ steps.build.outputs.zip_path }}
ASSET_NAME: ${{ steps.build.outputs.zip_name }}
ASSET_CONTENT_TYPE: application/zip
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
const fs = require('fs');
const { UPLOAD_URL, ASSET_PATH, ASSET_NAME, ASSET_CONTENT_TYPE } = process.env;
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
url: UPLOAD_URL,
headers: {
'content-type': ASSET_CONTENT_TYPE,
'content-length': fs.statSync(ASSET_PATH).size
},
name: ASSET_NAME,
data: fs.readFileSync(ASSET_PATH)
});
- name: Upload 7Zip
id: upload-7zip
uses: actions/github-script@v6
env:
UPLOAD_URL: ${{ needs.create_release.outputs.upload_url }}
ASSET_PATH: ${{ steps.build.outputs.seven_zip_path }}
ASSET_NAME: ${{ steps.build.outputs.seven_zip_name }}
ASSET_CONTENT_TYPE: application/x-7z-compressed
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
const fs = require('fs');
const { UPLOAD_URL, ASSET_PATH, ASSET_NAME, ASSET_CONTENT_TYPE } = process.env;
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
url: UPLOAD_URL,
headers: {
'content-type': ASSET_CONTENT_TYPE,
'content-length': fs.statSync(ASSET_PATH).size
},
name: ASSET_NAME,
data: fs.readFileSync(ASSET_PATH)
});
build_deb:
name: Build Debian Package
needs: [create_release, build_doc]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ui: [ { name: 'GTK3',
conf: '--enable-gtk3ui --with-pulse',
deps: 'libglew-dev libgtk-3-dev libpulse-dev' },
{ name: 'SDL2',
conf: '--enable-sdl2ui --with-sdlsound --without-pulse',
deps: 'libsdl2-dev libsdl2-image-dev' },
{ name: 'SDL1',
conf: '--enable-sdl1ui --with-sdlsound --without-pulse',
deps: 'libsdl1.2-dev libsdl-image1.2-dev' },
{ name: 'Headless',
conf: '--enable-headlessui --with-pulse',
deps: 'libpulse-dev' } ]
steps:
- shell: bash
run: git config --global core.autocrlf input
- name: Checkout Source
uses: actions/checkout@v3
- name: Download Documentation
uses: actions/download-artifact@v3
with:
name: vice-pdf
path: vice/doc/
- name: Install Dependencies
shell: bash
run: |
sudo apt update
sudo apt install -y autoconf automake build-essential byacc devscripts \
dos2unix fakeroot flex xa65
sudo apt install -y libasound-dev libflac-dev libgif-dev libmp3lame-dev \
libmpg123-dev libpcap-dev libpng-dev libvorbis-dev libcurl4-openssl-dev
sudo apt install -y ${{ matrix.ui.deps }}
- name: Build
shell: bash
run: |
mkdir -p build/usr
cd vice
./src/buildtools/genvicedate_h.sh
./autogen.sh
# ALSA is required for SDL2 as well for midi support
./configure --enable-option-checking=fatal --prefix=/usr --enable-arch=no \
--enable-ethernet --disable-pdf-docs --disable-html-docs \
--with-fastsid --with-resid --enable-cpuhistory --with-gif \
--with-png --with-vorbis --with-flac --with-mpg123 --with-lame \
--enable-midi --with-alsa --with-libcurl ${{ matrix.ui.conf }}
make -j2 -s --no-print-directory SVN_REVISION_OVERRIDE=$(echo "${{ github.ref }}" | sed 's/^.*r//')
# Don't use install-strip, we want symbols intact for backtraces
make DESTDIR=$HOME/build install
- name: Make Deb
id: make_deb
shell: bash
run: ./vice/build/github-actions/build-deb.sh ${{ matrix.ui.name }}
- name: Upload Deb
id: upload_deb
uses: actions/github-script@v6
env:
UPLOAD_URL: ${{ needs.create_release.outputs.upload_url }}
ASSET_PATH: ${{ steps.make_deb.outputs.deb_path }}
ASSET_NAME: ${{ steps.make_deb.outputs.deb_name }}
ASSET_CONTENT_TYPE: application/vnd.debian.binary-package
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
const fs = require('fs');
const { UPLOAD_URL, ASSET_PATH, ASSET_NAME, ASSET_CONTENT_TYPE } = process.env;
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
url: UPLOAD_URL,
headers: {
'content-type': ASSET_CONTENT_TYPE,
'content-length': fs.statSync(ASSET_PATH).size
},
name: ASSET_NAME,
data: fs.readFileSync(ASSET_PATH)
});
publish_release:
name: Publish Release
needs: [create_release, build]
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 3
script: |
await github.rest.repos.updateRelease(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create_release.outputs.release_id }},
draft: false
});
build_error_notify:
name: IRC Notification of Build Errors
needs: [cleanup_previous_builds, create_release, build_doc, build, publish_release]
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- shell: bash
run: git config --global core.autocrlf input
- name: Checkout Source
uses: actions/checkout@v3
- name: Notify IRC of Build Failure
env:
IRC_PASS: ${{ secrets.IRC_PASS }}
shell: bash
run: |
./vice/build/github-actions/irc-message.sh "tried to build $(echo "${{ github.ref }}" | sed 's,.*/,,') but it failed :( $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"