-
Notifications
You must be signed in to change notification settings - Fork 29
760 lines (760 loc) · 37.4 KB
/
Copy pathbuild-ci.yml
File metadata and controls
760 lines (760 loc) · 37.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
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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# GitHub Action to CI build SocNetV for all 3 major OSes
# Triggered only when the commit message contains [gha] or [ci]
name: Build SocNetV (CI) 🚀
on:
push:
branches:
- develop
env:
APP_NAME: "SocNetV"
UNIXNAME: "socnetv"
SOCNETV_VERSION: "3.6" # TODO - READ FROM FILE
VERSION: "3.6" # Will be overwritten by workflow with the dynamically determined version
QMAKE_PROJECT: "socnetv.pro"
PUBLISHER: "Dimitris Kalamaras"
QT_MODULES: "qtimageformats qt5compat qtcharts qtwebview"
QMAKE_CONFIG: release ## debug # Never use debug. Windows builds will break.
CMAKE_CONFIG: Release ## Debug
CORES: 16
MAC_ARTIFACT: ""
LINUX_ARTIFACT: ""
APPDIR_PREFIX: "/usr"
WINDOWS_ARTIFACT: ""
UPLOAD_URL: ''
BUILD_CLI: "OFF" # Set to ON to also build the headless regression CLI (socnetv-cli)
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
contents: write
if: contains(github.event.head_commit.message, '[ci]') || contains(github.event.head_commit.message, '[gha]')
steps:
- uses: actions/checkout@v4 # Checkout the repository to access the code and use gh CLI
- name: 🗑️ Delete old continuous assets
run: |
ASSETS=$(gh release view continuous --json assets -q '.assets[].name')
if [[ -z "$ASSETS" ]]; then
echo "✅ No previous assets found."
else
for ASSET in $ASSETS; do
echo "❌ Removing $ASSET..."
gh release delete-asset continuous "$ASSET" --yes
done
echo "✅ Old assets deleted."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ci_build:
needs: cleanup
permissions:
contents: write # Required to upload release assets
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-latest, macos-latest, windows-2022]
# NOTE:
# - We will CI build only for Qt6 LTS releases, see: https://doc.qt.io/qt-6/qt-releases.html
# - For the Qt Versions supported by aqtinstall, see: https://ddalcino.github.io/aqt-list-server/
qt-version: ['6.5.3', '6.8.0']
# exclude:
# - os: ubuntu-latest
# qt-version: '6.6.3'
# - os: windows-2022
# qt-version: '6.6.3'
# - os: macos-latest
# qt-version: '6.6.3'
# include:
# - os: macos-latest
# qt-version: '6.6.3'
# # Snapcraft
# - os: ubuntu-22.04
# qt-version: '6.5.3'
runs-on: ${{ matrix.os }}
if: contains(github.event.head_commit.message, '[ci]') || contains(github.event.head_commit.message, '[gha]')
steps:
- name: 🤖 Job information, on branch ${{ github.ref }}
run: |
echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event, by actor ${{ github.actor }}."
echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: 📂 Check out repository ${{ github.repository }}
uses: actions/checkout@v4
- name: 💡 List files cloned from the ${{ github.repository }}
run: |
ls ${{ github.workspace }}
echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
echo "🖥️ The workflow is now ready to test your code on the runner."
- name: 💡 Set version dynamically
shell: bash
id: set_version
run: |
# Check if this is a tagged commit
if [ -n "${GITHUB_REF}" ] && [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/} # Extract tag name
else
LAST_COMMIT_SHORT=$(git rev-parse --short HEAD)
VERSION="${SOCNETV_VERSION}-${LAST_COMMIT_SHORT}" # Use custom versioning for non-tagged commits
fi
# Export VERSION as an environment variable for subsequent steps
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Determined build version ${{ env.VERSION }}
run: echo "VERSION is set to ${{ env.VERSION }}"
- name: Check Rate Limit
uses: actions/github-script@v6
id: get_ratelimit
with:
script: |
const { data: rateLimit } = await github.rest.rateLimit.get();
console.log(rateLimit);
core.setOutput("rate_limit", rateLimit);
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Use script to get continuous release Upload URL
id: get_release
uses: actions/github-script@v6
with:
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const release = releases.find(r => r.tag_name === "continuous");
if (!release) {
console.log("Continuous release not found. Exiting gracefully.");
core.setOutput("upload_url", "");
} else {
core.setOutput("upload_url", release.upload_url);
}
result-encoding: string
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch 'continuous' release upload URL
shell: bash
id: fetch_release
run: |
echo "steps.get_ratelimit.outputs.rate_limit = ${{ steps.get_ratelimit.outputs.rate_limit }}"
echo "steps.get_release.outputs.upload_url = ${{ steps.get_release.outputs.upload_url }}"
if [ -z "${{ steps.get_release.outputs.upload_url }}" ]; then
echo "No continuous release found in get_release step."
fi
RELEASE_INFO=$(gh api -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ github.repository }}/releases/tags/continuous)
UPLOAD_URL=$(echo "$RELEASE_INFO" | jq -r '.upload_url' | sed 's/{?name,label}//')
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV
echo "UPLOAD_URL=${UPLOAD_URL}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# Install dependencies (build tools, cmake, etc)
#
- if: contains( matrix.os, 'windows')
name: 🪟 Prepare for buiilding on ${{matrix.os}}
run: |
echo '⚙️ Install dependencies for building....'
# DONT NEED IT. FOR DEBUG ONLY
# pip install aqtinstall
# aqt list-qt windows desktop
# aqt list-qt windows desktop --arch ${{ matrix.qt-version }}
# aqt list-qt windows desktop --modules ${{ matrix.qt-version }} win64_mingw
- if: contains( matrix.os, 'ubuntu')
name: 🐧 Prepare for building on ${{matrix.os}}
run: |
echo '⚙️ Install dependencies for building....'
sudo apt-get update
sudo apt-get install -y --fix-missing build-essential libssl-dev cmake ninja-build \
libxkbcommon-x11-dev libxcb-cursor-dev zlib1g-dev libcups2-dev libvulkan-dev \
desktop-file-utils patchelf libglu1-mesa-dev libfontconfig1 libfreetype6 libx11-dev libxext-dev \
libxrandr-dev libxrender-dev libxcb1-dev libx11-xcb-dev libxcb-glx0-dev
# libfuse2 was renamed to libfuse2t64 on Ubuntu 24.04 (noble)
sudo apt-get install -y libfuse2t64 2>/dev/null || sudo apt install -y libfuse2 2>/dev/null || true
# DONT NEED IT. FOR DEBUG ONLY
# pip install aqtinstall
# aqt list-qt linux desktop --long-modules ${{ matrix.qt-version }} win64_mingw
- if: contains( matrix.os, 'macos')
name: 🍎 Prepare for building on ${{matrix.os}}
run: |
echo '⚙️ Install dependencies for building....'
ls
# DONT NEED IT. FOR DEBUG ONLY
# pip install aqtinstall
# aqt list-qt mac desktop --modules ${{ matrix.qt-version }}
#
# Install Qt (using https://github.com/jurplel/install-qt-action)
#
- if: contains( matrix.os, 'windows')
name: Make sure MSVC is found
uses: ilammy/msvc-dev-cmd@v1
- if: contains( matrix.os, 'windows') && startsWith( matrix.qt-version, '6.' )
name: Install Qt ${{ matrix.qt-version }} on ${{ matrix.os }}
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*' # Use the default aqtinstall version
version: ${{ matrix.qt-version }} # Qt version to install
# arch: win64_mingw
# NOTE: We build with default arch:
# win64_msvc2019_64 if Qt < 6.8
# win64_msvc2022_64 if Qt >= 6.8
# see https://github.com/jurplel/install-qt-action
modules: ${{env.QT_MODULES}}
cache: true
- if: contains( matrix.os, 'ubuntu') && startsWith( matrix.qt-version, '6.' )
name: Install Qt 6 on ${{ matrix.os }}
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*' # Use the default aqtinstall version
version: ${{ matrix.qt-version }} # Qt version to install
modules: ${{env.QT_MODULES}}
cache: true
- if: contains( matrix.os, 'macos') && startsWith( matrix.qt-version, '6.' )
name: Install Qt 6 on macOS
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*' # Use the default aqtinstall version
version: ${{ matrix.qt-version }}
modules: ${{env.QT_MODULES}}
cache: true
#
# BUILD FOR LINUX
#
# Test building with qmake and Qt 6.5
- if: matrix.os == 'ubuntu-22.04' && matrix.qt-version == '6.5.3'
name: Build ${{ env.VERSION }} for ${{matrix.os}} with Qt${{matrix.qt-version}} using qmake
run: |
echo "🔎 Check openssl version:"
echo `openssl version`
echo "🔎 Check output of 'which qmake6':"
which qmake6
echo "🔎 Check qmake6 version:"
qmake6 -v
echo "🔧 Running qmake on ubuntu 22.04 with ${{env.QMAKE_CONFIG}}..."
qmake6 CONFIG+=${{env.QMAKE_CONFIG}}
echo "🚧 🛠️ Compiling for linux with make -j${{env.CORES}}. Please wait..."
make -j${{env.CORES}}
echo "👉 Building finished. Listing current directory with find for verification:"
find .
# Test building with cmake and newer versions of Qt
- if: matrix.os == 'ubuntu-22.04' && matrix.qt-version != '6.5.3'
name: Build ${{ env.VERSION }} for ${{matrix.os}} with Qt${{matrix.qt-version}} using cmake
run: |
echo "🔎 Check openssl version:"
echo `openssl version`
echo "💡 Checking current directory..."
pwd
echo "💡 List current directory..."
ls
echo "💡 Deleting old build subdirectory..."
rm -rf build
echo "🔧 Configuring project using 'cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} -DCMAKE_INSTALL_PREFIX=${{env.APPDIR_PREFIX}} -DBUILD_CLI=${{env.BUILD_CLI}}' ..."
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} \
-DCMAKE_INSTALL_PREFIX=${{env.APPDIR_PREFIX}} \
-DBUILD_CLI=${{env.BUILD_CLI}}
echo "🔎 Verifying ./build directory (before compiling)..."
if [[ -d "./build" ]]; then
echo "🎉 ./build directory created! Contents:"
ls -lh ./build/
else
echo "❌ Error! ./build directory was not created!"
exit 1
fi
echo "🚧 Compiling the project..."
cmake --build build -j$(nproc)
echo "🔎 Entering build directory..."
cd build
ls -lh .
echo "🔎 Search for built executable ./${{env.UNIXNAME}}*..."
if [[ -f "./${{env.UNIXNAME}}" ]]; then
echo "🎉 executable found!"
ls -ls "${{env.UNIXNAME}}"
else
echo "❌ Error! Executable was not created!"
exit 1
fi
# Build AppImage on ubuntu-22.04 with Qt 6.8 (latest LTS)
# Uses linuxdeploy + linuxdeploy-plugin-qt (supports Ubuntu 22.04+)
- if: matrix.os == 'ubuntu-22.04' && matrix.qt-version == '6.8.0'
name: Create AppImage ${{ env.VERSION }} for ${{matrix.os}} with Qt${{matrix.qt-version}}
run: |
echo "💡 Checking current directory..."
pwd
cd ./build/
echo "💡 List current directory (./build)..."
ls -lh .
echo "🔧 Installing the application into AppDir..."
cmake --install . --prefix AppDir/usr
if [[ ! -f "./AppDir/usr/bin/${{env.UNIXNAME}}" ]]; then
echo "❌ Error: Installation failed, binary not found in AppDir!"
exit 1
fi
echo "🎉 SocNetV installed into AppDir successfully!"
echo "🔧 Downloading linuxdeploy and Qt plugin..."
wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod a+x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-qt-x86_64.AppImage
echo "🚀 Creating AppImage using linuxdeploy..."
QMAKE=$(which qmake) \
LINUXDEPLOY_OUTPUT_VERSION="tmp-out" \
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--plugin qt \
--output appimage
ARTIFACT_FN="${{env.APP_NAME}}-${{env.VERSION}}-x86_64.AppImage"
# linuxdeploy names the output with the app name from the .desktop file
CREATED_APPIMAGE=$(ls ./*.AppImage 2>/dev/null | grep -v linuxdeploy | head -1)
if [[ -z "$CREATED_APPIMAGE" ]]; then
echo "❌ AppImage creation failed! No AppImage found."
exit 1
fi
mv "$CREATED_APPIMAGE" "$ARTIFACT_FN"
echo "🎉 AppImage created: $ARTIFACT_FN"
ls -lh ./*.AppImage
echo "LINUX_ARTIFACT=${ARTIFACT_FN}" >> $GITHUB_ENV
# Upload the AppImage artifact for Linux if it was created successfully
- if: matrix.os == 'ubuntu-22.04' && matrix.qt-version == '6.8.0' && env.LINUX_ARTIFACT != ''
name: 📤 Upload ${{matrix.os}} build artifacts of ${{env.APP_NAME}} ${{ env.VERSION }} to GitHub ${{ env.UPLOAD_URL }}
run: |
echo "🔍 Verifying artifact: ${{ env.LINUX_ARTIFACT }}"
pwd
ls build
if [ ! -f "./build/${{ env.LINUX_ARTIFACT }}" ]; then
echo "❌ Error: Artifact not found!"
exit 1
fi
echo "📤 Uploading artifact to GitHub release..."
gh release upload continuous "./build/${{ env.LINUX_ARTIFACT }}" --repo "${{ github.repository }}" \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# In latest ubuntu, we are test building with cmake. We do not upload the artifact.
- if: matrix.os == 'ubuntu-latest'
name: Build ${{ env.VERSION }} for ${{matrix.os}} with Qt ${{matrix.qt-version}} using cmake
run: |
echo "🔎 Check openssl version:"
echo `openssl version`
echo "💡 Checking current directory..."
pwd
echo "💡 List current directory..."
ls
echo "💡 Deleting old build subdirectory..."
rm -rf build
echo "🔧 Configuring project using 'cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} -DCMAKE_INSTALL_PREFIX=${{env.APPDIR_PREFIX}} -DBUILD_CLI=${{env.BUILD_CLI}}' ..."
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} -DCMAKE_INSTALL_PREFIX=${{env.APPDIR_PREFIX}} -DBUILD_CLI=${{env.BUILD_CLI}}
echo "🔎 Verifying ./build directory (before compiling)..."
if [[ -d "./build" ]]; then
echo "🎉 ./build directory created! Contents:"
ls -lh ./build/
else
echo "❌ Error! ./build directory was not created!"
exit 1
fi
echo "🚧 Compiling the project..."
cmake --build build -j$(nproc)
echo "🔎 Entering build directory..."
cd build
ls -lh .
echo "🔎 Search for built executable ./${{env.UNIXNAME}}*..."
if [[ -f "./${{env.UNIXNAME}}" ]]; then
echo "🎉 executable found!"
ls -ls "${{env.UNIXNAME}}"
else
echo "❌ Error! Executable not found in build directory!"
exit 1
fi
#
# BUILD FOR MACOS
#
# We test both qmake and cmake builds:
# In older Qt, we use qmake but we do not upload the artifact.
# We only upload the artifact for Qt 6.8.0, which is the latest LTS and the one we will use for the next release.
- if: contains( matrix.os, 'macos') && matrix.qt-version == '6.5.3'
name: Build ${{env.APP_NAME}} ${{ env.VERSION }} for ${{matrix.os}} with Qt ${{matrix.qt-version}} using qmake
run: |
echo "🍎 Preparing macOS build..."
echo "Building version: ${{env.VERSION}}"
# Ensure Qt is installed and in PATH
# export PATH="$(brew --prefix qt)/bin:$PATH"
which qmake
echo "🔧 Running 'qmake CONFIG+=${{env.QMAKE_CONFIG}} ${{env.QMAKE_PROJECT}}' to configure on macos..."
qmake CONFIG+=${{env.QMAKE_CONFIG}} ${{env.QMAKE_PROJECT}}
echo "🚧 🛠️ Compiling for macos with make. Please wait..."
make
echo "👉 Building finished! Searching for built ${{matrix.os}} bundle (DIRECTORY!)./${{env.APP_NAME}}.app ..."
if [[ -d "./${{env.APP_NAME}}.app" ]]; then
echo "🎉 ${{matrix.os}} bundle created! Bundle contents:"
find "${{env.APP_NAME}}.app"
else
echo "❌ Error! ${{matrix.os}} bundle not found !"
exit 1
fi
# Verify the binary with lipo
echo "🔎 Verifying architectures in the built binary..."
if [[ -f "${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}}" ]]; then
lipo -info "${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}}"
else
echo "❌ Error: Binary file not found!"
exit 1
fi
echo "🔧 Removing items we do not deploy from project dir ..."
rm -rf moc obj qrc
# Run macdeployqt WITHOUT -dmg to just bundle frameworks
echo "🚀 Running macdeployqt to bundle required libraries..."
macdeployqt "${{env.APP_NAME}}.app" -verbose=3 || {
echo "Error: macdeployqt failed."
exit 1
}
# Verify the bundled libraries
echo "🔎 Verify the bundled libraries in the built binary ..."
if [[ -f "${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}}" ]]; then
otool -L "${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}}"
else
echo "❌ Error: Binary file not found!"
exit 1
fi
# Create DMG manually
echo "📦 Creating DMG..."
hdiutil create -volname "${{env.APP_NAME}}" \
-srcfolder "${{env.APP_NAME}}.app" \
-ov -format UDZO "${{env.APP_NAME}}.dmg"
if [[ -f "${{env.APP_NAME}}.dmg" ]]; then
DMG_NAME="${{env.APP_NAME}}-${{env.VERSION}}.dmg"
mv "${{env.APP_NAME}}.dmg" "${DMG_NAME}"
echo "🎉 Build and packaging complete. Final DMG: ${DMG_NAME}"
ls -lh *.dmg
echo "MAC_ARTIFACT=${DMG_NAME}" >> $GITHUB_ENV
else
echo "❌ Error: DMG creation failed. No DMG file found."
exit 1
fi
# For the latest Qt 6.8.0, we build with cmake and upload the DMG artifact if it was created successfully.
- if: contains( matrix.os, 'macos') && matrix.qt-version != '6.5.3'
name: Build ${{env.APP_NAME}} ${{ env.VERSION }} for ${{matrix.os}} with Qt ${{matrix.qt-version}} using cmake
timeout-minutes: 360 # 6 hours maximum
run: |
echo "🍎 Preparing macOS build..."
echo "🔎 Check openssl version:"
echo `openssl version`
echo "💡 Checking current directory..."
pwd
echo "💡 List current directory..."
ls
echo "💡 Deleting old build subdirectory..."
rm -rf build
echo "🔧 Configuring project using 'cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} -DCMAKE_INSTALL_PREFIX=${{env.APPDIR_PREFIX}} -DBUILD_CLI=${{env.BUILD_CLI}}' ..."
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} -DCMAKE_INSTALL_PREFIX=${{env.APPDIR_PREFIX}} -DBUILD_CLI=${{env.BUILD_CLI}}
echo "🔎 Verifying ./build directory (before compiling)..."
if [[ -d "./build" ]]; then
echo "🎉 ./build directory created! Contents:"
ls -lh ./build/
else
echo "❌ Error! ./build directory was not created!"
exit 1
fi
echo "🚧 Compiling the project..."
cmake --build build -j$(sysctl -n hw.ncpu)
echo "🔎 Entering build directory..."
cd build
ls -lh .
echo "🔎 Search for built ${{matrix.os}} bundle (DIRECTORY!)./${{env.APP_NAME}}.app ..."
if [[ -d "./${{env.APP_NAME}}.app" ]]; then
echo "🎉 ${{matrix.os}} bundle created! Bundle contents:"
find "${{env.APP_NAME}}.app"
else
echo "❌ Error! ${{matrix.os}} bundle not found !"
exit 1
fi
# Verify the binary with lipo
echo "🔎 Verifying architectures in the ${{matrix.os}} bundle..."
if [[ -f "${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}}" ]]; then
lipo -info "${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}}"
else
echo "❌ Error: ${{env.APP_NAME}}.app/Contents/MacOS/${{env.APP_NAME}} file not found!"
exit 1
fi
echo "🔑 Import macOS Developer Certificate"
echo "${{ secrets.MACOS_CERTIFICATE }}" | base64 --decode > certificate.p12
security create-keychain -p "" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "" build.keychain
security import certificate.p12 -k build.keychain -P "${{ secrets.MACOS_CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -k "" build.keychain
rm -f certificate.p12
echo "🛠️ Store Apple ID Credentials for Notarization"
xcrun notarytool store-credentials "AC_PASSWORD" \
--apple-id "${{ secrets.AC_APPLE_ID }}" \
--team-id "${{ secrets.AC_TEAM_ID }}" \
--password "${{ secrets.AC_PASSWORD }}"
echo "🔧 Checking bundle structure before packaging..."
# Remove any PkgInfo file in the root of the app bundle
if [[ -f "${{env.APP_NAME}}.app/PkgInfo" ]]; then
echo "⚠️ Found PkgInfo in root directory - removing it"
rm "${{env.APP_NAME}}.app/PkgInfo"
fi
# Ensure PkgInfo exists in the Contents directory
if [[ ! -f "${{env.APP_NAME}}.app/Contents/PkgInfo" ]]; then
echo "Creating PkgInfo in Contents directory"
echo "APPL????" > "${{env.APP_NAME}}.app/Contents/PkgInfo"
fi
# Clear extended attributes that could interfere with signing
find "${{env.APP_NAME}}.app" -type f -exec xattr -c {} \;
# First run macdeployqt WITHOUT creating DMG yet
echo "🚀 Running macdeployqt to bundle required libraries..."
macdeployqt "${{env.APP_NAME}}.app" -verbose=3 || {
echo "Error: macdeployqt failed."
exit 1
}
# Now sign the .app bundle AFTER macdeployqt has added all dependencies
echo "🔏 Sign the application bundle"
codesign --deep --force --verbose \
--options runtime \
--entitlements ../scripts/entitlements.plist \
--sign "Developer ID Application: Dimitris Kalamaras (${{ secrets.AC_TEAM_ID }})" \
"${{env.APP_NAME}}.app"
# Verify the signature
echo "🔍 Verifying signature..."
codesign --verify --verbose "${{env.APP_NAME}}.app"
# Create the DMG from the signed app
echo "📦 Creating DMG from signed application..."
hdiutil create -volname "${{env.APP_NAME}}" -srcfolder "${{env.APP_NAME}}.app" -ov -format UDZO "${{env.APP_NAME}}.dmg"
# Sign the DMG
echo "🔏 Signing the DMG..."
codesign --force --sign "Developer ID Application: Dimitris Kalamaras (${{ secrets.AC_TEAM_ID }})" "${{env.APP_NAME}}.dmg"
# Before starting notarization, set keychain to not timeout
echo "🔐 Setting keychain to not timeout..."
security set-keychain-settings -t 72000 -l build.keychain
# Notarize the signed DMG
echo "📜 Notarize the DMG"
SUBMIT_OUTPUT=$(xcrun notarytool submit "${{env.APP_NAME}}.dmg" --keychain-profile "AC_PASSWORD")
NOTARY_SUBMISSION_ID=$(echo "$SUBMIT_OUTPUT" | grep "id:" | head -1 | awk '{print $2}')
echo "Notarization submission ID: $NOTARY_SUBMISSION_ID"
if [[ -z "$NOTARY_SUBMISSION_ID" ]]; then
echo "❌ Error: Notarization submission ID is empty!"
exit 1
fi
# Store the submission id
echo "NOTARY_SUBMISSION_ID=$NOTARY_SUBMISSION_ID" >> $GITHUB_ENV
echo "🕒 Waiting for notarization to complete (with timeout)..."
START_TIME=$(date +%s)
TIMEOUT_SECONDS=1800 # 30 minutes timeout
while true; do
# Check if we've exceeded the timeout
CURRENT_TIME=$(date +%s)
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
if [[ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]]; then
echo "⚠️ Notarization timeout after $(($TIMEOUT_SECONDS / 60)) minutes"
break
fi
# Explicitly unlock the keychain again before checking status
echo "🔓 Unlocking keychain before checking notarization status..."
security unlock-keychain -p "" build.keychain
# Check notarization status
echo "🔍 Checking notarization status..."
NOTARY_INFO=$(xcrun notarytool info --keychain-profile "AC_PASSWORD" "$NOTARY_SUBMISSION_ID" 2>&1)
echo "$NOTARY_INFO"
# Extract status
NOTARY_STATUS=$(echo "$NOTARY_INFO" | grep -i "status:" | awk '{print $2}' | tr -d '[:space:]')
if [[ "$NOTARY_STATUS" == "Accepted" ]]; then
echo "✅ Notarization successful!"
# Staple the notarization ticket to the DMG
echo "📌 Stapling notarization ticket to DMG..."
xcrun stapler staple "${{env.APP_NAME}}.dmg"
# Rename DMG file after successful notarization and stapling
DMG_NAME="${{env.APP_NAME}}-${{env.VERSION}}.dmg"
mv "${{env.APP_NAME}}.dmg" "${DMG_NAME}"
echo "🎉 Build, signing, notarization and stapling complete. Final DMG: ${DMG_NAME}"
ls -lh *.dmg
echo "MAC_ARTIFACT=${DMG_NAME}" >> $GITHUB_ENV
break
elif [[ "$NOTARY_STATUS" == "Invalid" || "$NOTARY_STATUS" == "Rejected" ]]; then
echo "❌ Notarization failed. Details:"
echo "$NOTARY_INFO"
# Get logs for failure details
xcrun notarytool log --keychain-profile "AC_PASSWORD" "$NOTARY_SUBMISSION_ID"
# Still create the artifact, but with a different name to indicate it's not notarized
DMG_NAME="${{env.APP_NAME}}-${{env.VERSION}}-unsigned.dmg"
mv "${{env.APP_NAME}}.dmg" "${DMG_NAME}"
echo "⚠️ Created unsigned DMG: ${DMG_NAME}"
echo "MAC_ARTIFACT=${DMG_NAME}" >> $GITHUB_ENV
break
elif [[ "$NOTARY_STATUS" == "In Progress" ]]; then
echo "⏳ Notarization still in progress, waiting..."
elif [[ "$NOTARY_STATUS" == "InProgress" ]]; then
echo "⏳ Notarization still in progress, waiting..."
else
echo "⚠️ Unexpected status: $NOTARY_STATUS"
echo "$NOTARY_INFO"
fi
echo "⏳ Still waiting for notarization... ($(($ELAPSED_TIME / 60)) minutes elapsed)"
sleep 60 # Check every minute
done
# Upload artifact for macOS if it was created
- if: contains( matrix.os, 'macos') && matrix.qt-version == '6.8.0' && env.MAC_ARTIFACT != ''
name: 📤 Upload ${{matrix.os}} build artifacts of ${{env.APP_NAME}} ${{ env.VERSION }} to GitHub ${{ env.UPLOAD_URL }}
run: |
echo "🔍 Verifying artifact: ${{ env.MAC_ARTIFACT }}"
pwd
ls build
if [ ! -f "./build/${{ env.MAC_ARTIFACT }}" ]; then
echo "❌ Error: Artifact not found!"
exit 1
fi
echo "📤 Uploading artifact to GitHub release..."
gh release upload continuous "./build/${{ env.MAC_ARTIFACT }}" --repo "${{ github.repository }}" \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# BUILD FOR WINDOWS
#
# Again we test build for both cmake and qmake.
#
# Test build with qmake for Qt 6.5.3
- if: contains( matrix.os, 'windows') && matrix.qt-version == '6.5.3'
name: Build ${{env.APP_NAME}} ${{ env.VERSION }} for ${{matrix.os}} with Qt ${{matrix.qt-version}} using qmake.
run: |
echo "🔎 Listing some directories"
dir D:\a\app\Qt\
echo "🔧 Running 'qmake6 CONFIG+=${{env.QMAKE_CONFIG}} ${{env.QMAKE_PROJECT}} -r' to configure the project on Windows..."
qmake6 CONFIG+=${{env.QMAKE_CONFIG}} TARGET.path=${{env.QMAKE_CONFIG}} ${{env.QMAKE_PROJECT}} -r
echo "🚧 🛠️ Compiling with nmake. Please wait..."
nmake
echo "👉 Building finished. Listing directory ${{env.QMAKE_CONFIG}} for verification:"
dir ${{env.QMAKE_CONFIG}}
#
# Build with cmake and newer LTS version of Qt (currently 6.8.0)
# Then, create installer with Inno Setup.
#
- if: contains( matrix.os, 'windows') && matrix.qt-version != '6.5.3'
name: Build ${{env.APP_NAME}} ${{ env.VERSION }} for ${{matrix.os}} with Qt ${{matrix.qt-version}} using cmake.
run: |
echo "🔎 Listing some directories"
dir D:\a\app\Qt\
echo "🔎 Verifying Qt installation path..."
where qmake
where windeployqt
echo "💡 Creating build dir"
mkdir build
echo "🔧 Running 'cmake -S . -B build' to configure the project..."
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.CMAKE_CONFIG}} -DBUILD_CLI=${{env.BUILD_CLI}}
echo "🚧 🛠️ Compiling into build/ with 'cmake --build build -j${{env.CORES}} --config ${{env.CMAKE_CONFIG}}'. Please wait..."
cmake --build build -j${{env.CORES}} --config ${{env.CMAKE_CONFIG}} -v
echo "👉 Building finished. Entering build/ and listing it for verification: "
cd build
dir
echo "🔧 Running windeployqt on built executable (and ensuring required .dlls are copied into the folder)..."
windeployqt ${{env.CMAKE_CONFIG}}\socnetv.exe --release --compiler-runtime
echo "🔧 Manually copying MSVC runtime DLLs..."
if (!(Test-Path "C:\Windows\System32\MSVCP140_1.dll")) {
echo "❌ MSVCP140_1.dll NOT FOUND in System32! This may cause runtime errors."
exit 1 # Fail the build when the file is missing
}
if (!(Test-Path "C:\Windows\System32\MSVCP140_2.dll")) {
echo "❌ MSVCP140_2.dll NOT FOUND in System32! This may cause runtime errors."
exit 1 # Fail the build when the file is missing
}
copy "C:\Windows\System32\MSVCP140.dll" ${{env.CMAKE_CONFIG}}\
copy "C:\Windows\System32\MSVCP140_1.dll" ${{env.CMAKE_CONFIG}}\
copy "C:\Windows\System32\MSVCP140_2.dll" ${{env.CMAKE_CONFIG}}\
copy "C:\Windows\System32\VCRUNTIME140.dll" ${{env.CMAKE_CONFIG}}\
copy "C:\Windows\System32\VCRUNTIME140_1.dll" ${{env.CMAKE_CONFIG}}\
copy "C:\Windows\System32\CONCRT140.dll" ${{env.CMAKE_CONFIG}}\
echo "🔧 Copying license file to build directory..."
copy ..\COPYING ${{env.CMAKE_CONFIG}}\LICENSE.txt
echo "👉 Checking deployed DLLs..."
dir ${{env.CMAKE_CONFIG}}
if (!(Get-Command "iscc.exe" -ErrorAction SilentlyContinue)) {
echo "🔧 Installing Inno Setup..."
choco install -y InnoSetup
} else {
echo "Inno Setup is already installed. Skipping installation."
}
echo "🔧 Adding Inno Setup to PATH..."
$env:PATH += ";C:\Program Files (x86)\Inno Setup 6\"
echo "🔧 Verifying Inno Setup Installation..."
iscc.exe /?
echo "🔧 Copying InnoSetup script..."
copy ..\scripts\innosetup.iss innosetup.iss
echo "Updating RELEASEFOLDER in innosetup.iss with ${{env.CMAKE_CONFIG}}..."
$config = "${{env.CMAKE_CONFIG}}"
$replacement = "#define RELEASEFOLDER `"$config\\`""
(Get-Content innosetup.iss) -replace '#define RELEASEFOLDER "release\\"', $replacement | Set-Content innosetup.iss
echo "Updated innosetup.iss:"
type innosetup.iss
echo "🔧 Running Inno Setup to create installer..."
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "innosetup.iss"
echo "👉 Checking if installer exists in current directory ..."
dir
$originalInstaller = Get-ChildItem -Path "SocNetV-*installer.exe" -ErrorAction SilentlyContinue
if (-not $originalInstaller) {
echo "❌ Error: Installer file not found!"
exit 1
}
echo "🔧 Renaming installer..."
$installerName = "SocNetV-${{env.VERSION}}-windows-installer.exe"
Get-ChildItem -Path "SocNetV-*installer.exe" | Move-Item -Destination $installerName
dir
echo "🎉 Exporting installer name to environment variable..."
echo "WINDOWS_ARTIFACT=$installerName" >> $env:GITHUB_ENV
echo "🎉 Windows build complete. Artifacts are ready!"
#
# Upload artifacts from Windows build to 'continuous' pre-release tag.
# NOTE: We only upload from Windows when building with Qt 6.8,
# to avoid uploading too many artifacts for every commit.
#
- if: contains( matrix.os, 'windows') && matrix.qt-version == '6.8.0' && env.WINDOWS_ARTIFACT != ''
name: 📤 Upload ${{matrix.os}} build artifacts of ${{env.APP_NAME}} ${{ env.VERSION }} to GitHub ${{ env.UPLOAD_URL }}
run: |
echo "🔍 Verifying artifact: ${{ env.WINDOWS_ARTIFACT }}"
echo "Current working directory:"
pwd
echo "Contents of build directory:"
Get-ChildItem -Path build
if (!(Test-Path -Path "./build/${{ env.WINDOWS_ARTIFACT }}")) {
echo "❌ Error: Artifact not found!"
exit 1
}
echo "📤 Uploading artifact to GitHub release..."
gh release upload continuous "./build/${{ env.WINDOWS_ARTIFACT }}" `
--repo "${{ github.repository }}" `
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "🍏 This job's status is ${{ job.status }}."
#
# Update the continuous release description (only once, from ubuntu)
#
- if: matrix.os == 'ubuntu-latest' && matrix.qt-version == '6.8.0'
name: 🔄 Update continuous release description
uses: actions/github-script@v6
with:
script: |
const commitSha = context.sha;
const shortSha = commitSha.slice(0, 7);
const commitDate = new Date().toISOString().split('T')[0];
const { data: commit } = await github.rest.git.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: commitSha
});
const commitMessage = commit.message.split('\n')[0];
const newDescription = `Latest Continuous Build. Built from commit \`${shortSha}\` on ${commitDate}. This is an automated continuous build. These builds are generated automatically from the latest \`develop\` code and are intended for testing purposes.`;
try {
// Find the continuous release
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const release = releases.find(r => r.tag_name === "continuous");
if (release) {
// Update the release description
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
body: newDescription
});
console.log("Release description updated successfully");
} else {
console.log("Continuous release not found");
}
} catch (error) {
console.error("Error updating release description:", error);
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}