-
Notifications
You must be signed in to change notification settings - Fork 0
473 lines (391 loc) Β· 18.5 KB
/
build.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
467
468
469
470
471
472
473
#
# .github/workflows/build.yml
#
# Copyright 2022 Jens A. Koch.
# SPDX-License-Identifier: MIT
# This file is part of jakoch/wikifolio_universe_converter.
#
name: Build
on:
- push
- pull_request
# You can manually run this workflow.
- workflow_dispatch
# improve CI concurrency by automatically cancelling outdated jobs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
# ---------------------------------------------------------------------------------------
build-on-windows:
# ---------------------------------------------------------------------------------------
name: ${{ matrix.config.job_name }}
# https://github.com/actions/runner-images#available-environments
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
runs-on: ${{ matrix.config.OS }}
strategy:
fail-fast: false
matrix:
config:
# Compiler Versions Overview for Github Actions Windows Images (01-2024)
# ----------------------------------------------------------------------
# OSβ Compiler->| VC | Clang-Cl | GNU C++ | LLVM Clang
# --------------|-------|----------|---------|--------------------------
# windows-2019 | 16.11 | | 8.1.0 | 16.0.6
# windows-2022 | 17.8 | | 12.2.0 | 16.0.6
- { os: windows-2019, preset: "vc16-x64-windows-static-rel-ci", job_name: "Win | VC-16 | Release" }
- { os: windows-2022, preset: "vc17-x64-windows-static-rel-ci", job_name: "Win | VC-17 | Release" }
- { os: windows-2022, preset: "vc17-x64-windows-static-rdi-ci", job_name: "Win | VC-17 | RelWithDebInfo" }
env:
# We can not set VCPKG_ROOT here, because its redefined by action "ilammy/msvc-dev-cmd@1".
#VCPKG_ROOT: C:\vcpkg
VCPKG_DISABLE_METRICS: 1
defaults:
run:
shell: cmd
steps:
- name: π€ Checkout Code
uses: actions/checkout@v4 # https://github.com/actions/checkout
# https://community.chocolatey.org/packages/ninja
# https://community.chocolatey.org/packages/cmake
- name: π½ Install Ninja
run: choco install ninja cmake
# Build Artifact Name: wiuc-1.0.1-0cda6a2-vc17-x64-win
- name: β Fetch Versioning Data & Set Artifact Name
shell: pwsh
run: |
$NAME='wiuc'
$VERSION=$(jq -r .version vcpkg.json)
$SHORT_HASH=$($env:GITHUB_SHA.substring(0,7))
$PRESET=$('${{ matrix.config.preset }}').replace('-windows-static', '-win').replace('-rel', '').replace('-ci', '')
$ARTIFACT_NAME="$NAME-$VERSION-$SHORT_HASH-$PRESET"
echo "Artifact Name:" $ARTIFACT_NAME
echo "ARTIFACT_NAME=$($ARTIFACT_NAME)" >> $env:GITHUB_ENV
echo "VERSION=$($VERSION)" >> $env:GITHUB_ENV
# WARNING
# ENV VCPKG_ROOT is redefined by this action
# and set to "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\vcpkg"
# instead of "c:\vcpkg", which is important for the pre-installed VCPKG on GHA.
- name: π οΈ Setup Visual Studio Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
# Default Location is "c:\vcpkg"
- name: π½ Define VCPKG_ROOT
shell: pwsh
run: |
$VCPKG_ROOT=$($env:VCPKG_INSTALLATION_ROOT)
echo "VCPKG_ROOT=$($VCPKG_ROOT)" >> $env:GITHUB_ENV
# Reminder: This step requires that the CMakePresets for CI contain
# "CMAKE_CXX_COMPILER_LAUNCHER": "sccache".
- name: π― Setup Build Cache
uses: hendrikmuhs/ccache-action@v1
with:
variant: sccache
key: cache-build-${{ matrix.config.preset }}-${{ github.ref }}
restore-keys: |
cache-build-${{ matrix.config.preset }}-${{ github.ref }}
cache-build-${{ matrix.config.preset }}
- name: π― Setup VCPKG Cache
id: cache-vcpkg
uses: actions/cache@v4 # https://github.com/actions/cache
with:
# https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md#configuration
path: |
${{ env.VCPKG_ROOT }}\packages
~\AppData\Local\vcpkg\archives\
key: cache-win-vcpkg-${{ matrix.config.preset }}-${{ github.ref }}
restore-keys: |
cache-vcpkg-${{ matrix.config.preset }}-${{ github.ref }}
cache-vcpkg-${{ matrix.config.preset }}
- name: π½ Update VCPKG to latest TAG
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: bash
run: |
set -euo pipefail
cd "${{ env.VCPKG_ROOT }}"
git fetch --tags
LATEST_VCPKG_TAG=$(git describe --tags --abbrev=0)
git checkout $LATEST_VCPKG_TAG
- name: π½ Bootstrap + Integrate VCPKG
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
bootstrap-vcpkg.bat
vcpkg integrate
- name: β CMake β Configure
run: cmake --preset=${{ matrix.config.PRESET }}
- name: π CMake β Build
run: cmake --build --preset=${{ matrix.config.PRESET }}
- name: π¦ CMake β Install
run: cmake --install out/build/${{ matrix.config.PRESET }} --verbose
- name: β CHECK important folders, to see if everything is present (after building)
run: |
dir /S /B out\build\${{ matrix.config.preset }}
dir /S /B out\install
- name: π₯ Prepare Build Artifact (copy to packaging folder and rename)
run: |
mkdir artifact
xcopy /E out\install\${{ matrix.config.preset }} artifact
- name: πΌ Upload Build Artifact (on commit)
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
if: always()
with:
name: ${{ env.ARTIFACT_NAME }}
path: artifact/**/*
# ---------------------------------------------------------------------------------------
build-on-linux:
# ---------------------------------------------------------------------------------------
name: ${{ matrix.config.job_name }}
# https://github.com/actions/runner-images#available-environments
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
# Compiler Versions Overview for Github Actions Linux Images (01-2024)
# ------------------------------------------------------------------------
# OSβ Compiler->| GNU C++ | LLVM Clang
# --------------|----------------------------------------|-------------------------
# ubuntu-20.04 | 9.4.0, 10.5.0 | 10.0.0, 11.0.0, 12.0.0
# ubuntu-22.04 | 9.5.0, 10.5.0, 11.4.0, 12.3.0 | 13.0.1, 14.0.0, 15.0.7
# ubuntu-24.04 | 12,13,14 | 16,17,18 (default)
- { os: ubuntu-20.04, preset: "gcc9-x64-linux-rel-ci", apt_packages: "g++-9", job_name: "Linux | GCC-9 | Release" }
- { os: ubuntu-24.04, preset: "gcc13-x64-linux-rel-ci", apt_packages: "g++-13", job_name: "Linux | GCC-13 | Release" }
- { os: ubuntu-24.04, preset: "gcc14-x64-linux-rel-ci", apt_packages: "g++-14", job_name: "Linux | GCC-14 | Release" }
- { os: ubuntu-20.04, preset: "clang10-x64-linux-rel-ci", apt_packages: "clang-10", job_name: "Linux | Clang-10 | Release" }
- { os: ubuntu-22.04, preset: "clang15-x64-linux-rel-ci", apt_packages: "clang-15", job_name: "Linux | Clang-15 | Release" }
- { os: ubuntu-24.04, preset: "clang18-x64-linux-rel-ci", apt_packages: "clang-18", job_name: "Linux | Clang-18 | Release" }
env:
VCPKG_ROOT: /usr/local/share/vcpkg
VCPKG_DISABLE_METRICS: 1
steps:
- name: π€ Checkout Code
uses: actions/checkout@v4 # https://github.com/actions/checkout
# Build Artifact Name: wiuc-1.0.1-0cda6a2-clang17-x64-linux
- name: β Fetch Versioning Data & Set Artifact Name
run: |
NAME='wiuc'
VERSION=$(jq -r .version vcpkg.json)
SHORT_HASH=`echo $GITHUB_SHA | cut -c1-8`
PRESET=`echo ${{ matrix.config.preset }} | sed 's/-rel-ci//'`
ARTIFACT_NAME="$NAME-$VERSION-$SHORT_HASH-$PRESET"
echo "Artifact Name: $ARTIFACT_NAME"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
# openssl requires Linux kernel headers from the system package manager:
# linux-libc-dev for openssl, which is fechted and build via vcpkg.
- name: π½ Update Build Environment (update/install packages)
run: |
sudo apt update -qq
sudo apt install linux-libc-dev ninja-build ${{ matrix.config.apt_packages }} -y
sudo ln -s /usr/bin/ninja /usr/bin/ninja-build
# Reminder: This step requires that the CMakePresets for CI contain
# "CMAKE_CXX_COMPILER_LAUNCHER": "sccache".
- name: π― Setup Build Cache
uses: hendrikmuhs/ccache-action@v1
with:
key: cache-build-${{ matrix.config.preset }}-${{ github.ref }}
restore-keys: |
cache-build-${{ matrix.config.preset }}-${{ github.ref }}
cache-build-${{ matrix.config.preset }}
- name: π― Cache VCPKG
id: cache-vcpkg
uses: actions/cache@v4 # https://github.com/actions/cache
with:
# https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md#configuration
path: /home/runner/.cache/vcpkg/archives/
key: cache-vcpkg-${{ matrix.config.preset }}-${{ github.ref }}
restore-keys: |
cache-vcpkg-${{ matrix.config.preset }}-${{ github.ref }}
cache-vcpkg-${{ matrix.config.preset }}
- name: π½ Update VCPKG
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
cd ${{ env.VCPKG_ROOT }}
git reset --hard
git pull --quiet
./bootstrap-vcpkg.sh
- name: β CMake β Configure
run: cmake --preset=${{ matrix.config.PRESET }}
- name: π CMake β Build
run: cmake --build --preset=${{ matrix.config.PRESET }}
- name: π¦ CMake β Install
run: cmake --install out/build/${{ matrix.config.PRESET }} --verbose
- name: β CHECK important folders, to see if everything is present (after building)
run: |
ls out/build/${{ matrix.config.preset }}
ls out/install/${{ matrix.config.preset }}
- name: π₯ Prepare Build Artifact (copy to packaging folder)
run: |
mkdir artifact
cp -r out/install/${{ matrix.config.preset }} artifact/
#
# The uploaded artifact will be a zip file named, e.g. "wiuc-1.0.3-2399e873-Clang14-x64-linux-Release".
# The binary inside the zip is named "wiuc".
#
- name: πΌ Upload Build Artifact (on every commit)
if: always()
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: artifact/**/*
# ---------------------------------------------------------------------------------------
build-on-container:
# ---------------------------------------------------------------------------------------
name: ${{ matrix.config.job_name }}
runs-on: ubuntu-latest
container: ghcr.io/jakoch/cpp-devbox:${{ matrix.config.image_version }}
strategy:
fail-fast: false
matrix:
config:
- { image_version: "latest", preset: "clang17-x64-linux-rel-ci", job_name: "Linux | Clang-17 | Release" }
#- { preset: "clang18-x64-linux-rel-ci", job_name: "Linux | Clang-18 | Release" }
env:
VCPKG_ROOT: /opt/vcpkg
VCPKG_DISABLE_METRICS: 1
steps:
- name: π€ Checkout Code
uses: actions/checkout@v4 # https://github.com/actions/checkout
# Build Artifact Name: wiuc-1.0.1-0cda6a2-clang17-x64-linux-rel
- name: β Fetch Versioning Data & Set Artifact Name
run: |
NAME='wiuc'
VERSION=$(jq -r .version vcpkg.json)
SHORT_HASH=`echo $GITHUB_SHA | cut -c1-8`
PRESET=`echo ${{ matrix.config.preset }} | sed 's/-ci//'`
ARTIFACT_NAME="$NAME-$VERSION-$SHORT_HASH-$PRESET"
echo "Artifact Name: $ARTIFACT_NAME"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
# openssl requires Linux kernel headers from the system package manager:
# linux-libc-dev for openssl, which is fechted and build via vcpkg.
- name: π½ Update Build Environment (update/install packages)
run: |
sudo apt update -qq
sudo apt install linux-libc-dev ninja-build -y
sudo ln -s /usr/bin/ninja /usr/bin/ninja-build
# Reminder: This step requires that the CMakePresets for CI contain
# "CMAKE_CXX_COMPILER_LAUNCHER": "sccache".
- name: π― Setup Build Cache
uses: hendrikmuhs/ccache-action@v1
with:
key: cache-build-${{ matrix.config.preset }}-${{ github.ref }}
restore-keys: |
cache-build-${{ matrix.config.preset }}-${{ github.ref }}
cache-build-${{ matrix.config.preset }}
- name: π― Cache VCPKG
id: cache-vcpkg
uses: actions/cache@v4 # https://github.com/actions/cache
with:
# https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md#configuration
path: /home/runner/.cache/vcpkg/archives/
key: cache-vcpkg-${{ matrix.config.preset }}-${{ github.ref }}
restore-keys: |
cache-vcpkg-${{ matrix.config.preset }}-${{ github.ref }}
cache-vcpkg-${{ matrix.config.preset }}
- name: π½ Update VCPKG
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
cd ${{ env.VCPKG_ROOT }}
git reset --hard
git pull --quiet
./bootstrap-vcpkg.sh
- name: β CMake β Configure
run: cmake --preset=${{ matrix.config.PRESET }}
- name: π CMake β Build
run: cmake --build --preset=${{ matrix.config.PRESET }}
- name: π¦ CMake β Install
run: cmake --install out/build/${{ matrix.config.PRESET }} --verbose
- name: β CHECK important folders, to see if everything is present (after building)
run: |
ls out/build/${{ matrix.config.preset }}
ls out/install/${{ matrix.config.preset }}
- name: π₯ Prepare Build Artifact (copy to packaging folder)
run: |
mkdir artifact
cp -r out/install/${{ matrix.config.preset }} artifact/
#
# The uploaded artifact will be a zip file named, e.g. "wiuc-1.0.3-2399e873-Clang14-x64-linux-Release".
# The binary inside the zip is named "wiuc".
#
- name: πΌ Upload Build Artifact (on every commit)
if: always()
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: artifact/**/*
# ---------------------------------------------------------------------------------------
github-release:
# ---------------------------------------------------------------------------------------
name: Draft GitHub Release
runs-on: ubuntu-latest
needs:
- build-on-windows
- build-on-linux
# on tag push
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
TAG: ${{ github.ref_name }}
steps:
- name: π€ Checkout repository
uses: actions/checkout@v4 # https://github.com/actions/checkout
# This downloads all artifact zip archives and extracts them into folders.
# So we have to zip them for release again.... Β―\_(γ)_/Β―
# We are waiting for the "extractArtifact" option, referencing:
# # https://github.com/actions/download-artifact/issues/143
#
- name: π½ Download all artifacts from previous jobs
uses: actions/download-artifact@v4 # https://github.com/actions/download-artifact
# with:
# extractArtifact: false # not yet available
- name: Display downloaded files
run: |
ls -R
- name: Delete all non-release artifact folders
run: |
rm -rf *-RelWithDebInfo
rm -rf *-Clang10-*
rm -rf *-GCC9-*
rm -rf *-VC16-*
ls -R wiuc*
# zip with -j to only include files of the folder and not the folder itself
- name: Zip release folders
run: |
for dir in ./wiuc*/ ; do zip -jr "${dir%/}.zip" "$dir"; done
ls -R
- name: Delete release folders
run: find . -maxdepth 1 -type d -name 'wiuc*' -exec rm -r {} +
# The regexp uses named groups for matching:
# IN (?P<name>wiuc)-(?P<version>.*)-(?P<commit>.*)-(?P<compiler>.*)-(?P<arch>.*)-(?P<os>.*)-(?:(?P<linktype>[^-]*)-)?Release.zip
#
# And only some of the matched groups for building the filename:
# OUT $+{name}-$+{version}-$+{compiler}-$+{arch}-$+{os}.zip/
#
# wiuc-1.0.4-4f5b959-VC17-x64-windows-static-Release.zip
# ->
# wiuc-1.0.4-VC17-x64-windows.zip
#
- name: Install rename
run: sudo apt update && sudo apt install -y rename
- name: Rename zip files using a named group regexp
env:
ARTIFACT_REGEXP: '^(?P<name>wiuc)-(?P<version>[\d.]+)-(?P<commit>[\da-f]+)-(?P<compiler>[A-Za-z\d]+)-(?P<arch>[A-Za-z\d]+)-(?P<os>linux|windows|mac)-?(?P<linktype>static)?-Release\.zip$'
RELEASE_REGEXP: '$+{name}-$+{version}-$+{compiler}-$+{arch}-$+{os}.zip'
run: |
for file in *.zip; do (rename "s/$ARTIFACT_REGEXP/$RELEASE_REGEXP/" "$file"); done
ls -R
- name: Extract Release Notes from Changelog
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v2 # https://github.com/ffurrer2/extract-release-notes
- name: π Create Draft Release
# https://cli.github.com/manual/gh_release_create
env:
RELEASE_NOTES: ${{ steps.extract-release-notes.outputs.release_notes }}
run: |
gh release create $TAG --title "Release $TAG" --notes "$RELEASE_NOTES" --draft
- name: π¦ Create Github Release
# https://cli.github.com/manual/gh_release_upload
run: |
gh release upload $TAG *.zip