forked from foldynl/QLog
-
Notifications
You must be signed in to change notification settings - Fork 1
320 lines (263 loc) · 13 KB
/
macOSBuild.yml
File metadata and controls
320 lines (263 loc) · 13 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: macOS deployment
#on: [push, pull_request]
on:
workflow_dispatch:
push:
branches:
- master
jobs:
macos-build:
name: MacOS Build
strategy:
matrix:
os: [macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Dependencies
run: |
unset HOMEBREW_NO_INSTALL_FROM_API
brew update
brew upgrade || true
brew install qt6
brew install qtvirtualkeyboard
brew link qt6 --force
brew install hamlib
brew link hamlib --force
brew install qtkeychain
brew install dbus-glib
brew install brotli
brew install icu4c
brew install pkg-config
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Get version from tag
run : |
TAGVERSION=$(git describe --tags)
echo "TAGVERSION=${TAGVERSION:1}" >> $GITHUB_ENV
- name: Configure and compile
run: |
mkdir -p build
cd build
qmake -config release ..
make -j4
- name: Build app
run: |
set -euo pipefail
cd build
APP="qlog.app"
# 1) Deploy first (creates Contents/Frameworks etc.)
macdeployqt "$APP" \
-always-overwrite \
-verbose=2 \
-executable="$APP/Contents/MacOS/qlog" \
-qmldir=..
# 2) Ensure Frameworks folder exists (macdeployqt should do this, but guard anyway)
mkdir -p "$APP/Contents/Frameworks"
# 3) (Optional) copy extra non-Qt dylibs AFTER deploy
ICU_PATH="$(brew --prefix icu4c)/lib"
cp "$(brew --prefix)"/lib/libhamlib.dylib "$APP/Contents/Frameworks/" || true
cp "$(brew --prefix)"/lib/libqt6keychain.dylib "$APP/Contents/Frameworks/" || true
cp "$ICU_PATH"/libicui18n*.dylib "$APP/Contents/Frameworks/" || true
# 4) Patch QtWebEngineProcess helper to stop using /opt/homebrew
HELPER_BIN="$APP/Contents/Frameworks/QtWebEngineCore.framework/Versions/A/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess"
echo "Helper deps BEFORE:"
otool -L "$HELPER_BIN" | sed 's/^/ /'
# Add rpath so @rpath/Qt*.framework resolves to app Frameworks
install_name_tool -add_rpath "@executable_path/../../../../../../../../Frameworks" "$HELPER_BIN" || true
# Rewrite any hardcoded Homebrew Qt framework references to @rpath equivalents
# (This handles QtOpenGL, QtQuick, etc.)
while read -r dep; do
# dep looks like: /opt/homebrew/opt/qtbase/lib/QtOpenGL.framework/Versions/A/QtOpenGL
fw="$(basename "$dep")" # QtOpenGL
fwdir="$(basename "$(dirname "$(dirname "$(dirname "$dep")")")")" # QtOpenGL.framework
install_name_tool -change "$dep" "@rpath/$fwdir/Versions/A/$fw" "$HELPER_BIN" || true
done < <(otool -L "$HELPER_BIN" | awk '{print $1}' | grep '^/opt/homebrew/opt/qt.*/lib/Qt.*\.framework/')
# Remove brew rpaths if present
install_name_tool -delete_rpath "/opt/homebrew/opt/qtbase/lib" "$HELPER_BIN" || true
install_name_tool -delete_rpath "/opt/homebrew/opt/qtdeclarative/lib" "$HELPER_BIN" || true
echo "Helper deps AFTER:"
otool -L "$HELPER_BIN" | sed 's/^/ /'
otool -l "$HELPER_BIN" | grep -A2 LC_RPATH || true
- name: Codesign app bundle
env:
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }} # base64 p12
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }} # p12 password
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }} # "Developer ID Application: ... (TEAMID)"
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
run: |
set -euo pipefail
APP="$GITHUB_WORKSPACE/build/qlog.app"
ENT="$GITHUB_WORKSPACE/entitlements.xml"
KEYCHAIN="$RUNNER_TEMP/build.keychain-db"
echo "Entitlements:"
ls -l "$ENT"
echo "== Create+unlock CI keychain =="
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" "$KEYCHAIN"
security set-keychain-settings -lut 21600 "$KEYCHAIN"
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" "$KEYCHAIN"
security list-keychains -d user -s "$KEYCHAIN"
security default-keychain -d user -s "$KEYCHAIN"
echo "== Import signing cert (.p12) =="
echo "$MACOS_CERTIFICATE" | base64 --decode > "$RUNNER_TEMP/cert.p12"
security import "$RUNNER_TEMP/cert.p12" -k "$KEYCHAIN" -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign -T /usr/bin/security
# allow codesign to access the key without UI prompts
security set-key-partition-list -S apple-tool:,apple: -s -k "$MACOS_CI_KEYCHAIN_PWD" "$KEYCHAIN"
echo "== Confirm identity =="
security find-identity -v -p codesigning "$KEYCHAIN" || true
echo "== 1) Sign frameworks/plugins/dylibs first (NO entitlements) =="
while IFS= read -r -d '' F; do
/usr/bin/codesign --force --timestamp --options runtime \
-s "$MACOS_CERTIFICATE_NAME" "$F"
done < <(
find "$APP" -type f -print0 | while IFS= read -r -d '' F; do
if file "$F" | grep -q "Mach-O"; then
# skip QtWebEngineProcess here; we'll sign it with entitlements below
if [[ "$F" == *"/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess" ]]; then
continue
fi
printf '%s\0' "$F"
fi
done
)
echo "== 2) Sign ALL QtWebEngineProcess binaries WITH entitlements =="
mapfile -t WEBENGINE_BINS < <(find "$APP" -path "*QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess" -type f)
if [[ "${#WEBENGINE_BINS[@]}" -eq 0 ]]; then
echo "ERROR: no QtWebEngineProcess binary found"
exit 1
fi
for BIN in "${WEBENGINE_BINS[@]}"; do
echo "Signing WebEngine helper bin: $BIN"
/usr/bin/codesign --force --timestamp --options runtime \
--entitlements "$ENT" \
-s "$MACOS_CERTIFICATE_NAME" "$BIN"
done
echo "== 3) Sign ALL QtWebEngineProcess.app bundles WITH entitlements =="
mapfile -t WEBENGINE_APPS < <(find "$APP" -path "*QtWebEngineProcess.app" -type d)
for HAPP in "${WEBENGINE_APPS[@]}"; do
echo "Signing WebEngine helper app: $HAPP"
/usr/bin/codesign --force --timestamp --options runtime \
--entitlements "$ENT" \
-s "$MACOS_CERTIFICATE_NAME" "$HAPP"
done
echo "== 4) Sign top-level app WITH entitlements =="
/usr/bin/codesign --force --timestamp --options runtime \
--entitlements "$ENT" \
-s "$MACOS_CERTIFICATE_NAME" "$APP"
echo "== 5) Verify + prove entitlements stuck =="
/usr/bin/codesign --verify --deep --strict --verbose=4 "$APP"
echo "Entitlements on one QtWebEngineProcess binary (should NOT be empty):"
/usr/bin/codesign -d --entitlements :- "${WEBENGINE_BINS[0]}" || true
spctl -a -t exec -vv "$APP"
- name: "Notarize app bundle"
env:
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
run: |
set -euo pipefail
echo "Create keychain profile"
xcrun notarytool store-credentials "notarytool-profile" \
--apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" \
--team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" \
--password "$PROD_MACOS_NOTARIZATION_PWD"
echo "Creating temp notarization archive"
ditto -c -k --keepParent "/Users/runner/work/QLog/QLog/build/qlog.app" "notarization.zip"
echo "Notarize app (submit + wait)"
xcrun notarytool submit "notarization.zip" \
--keychain-profile "notarytool-profile" \
--wait \
--output-format json > notarization_log.json
cat notarization_log.json
# Extract id + status (no jq needed)
NOTARY_ID=$(python3 -c 'import json; print(json.load(open("notarization_log.json"))["id"])')
NOTARY_STATUS=$(python3 -c 'import json; print(json.load(open("notarization_log.json"))["status"])')
echo "Notary Request ID: $NOTARY_ID"
echo "Notary Status: $NOTARY_STATUS"
echo "Fetching detailed notary log..."
xcrun notarytool log "$NOTARY_ID" --keychain-profile "notarytool-profile" || true
if [ "$NOTARY_STATUS" != "Accepted" ]; then
echo "Notarization failed with status: $NOTARY_STATUS"
exit 1
fi
echo "Attach staple"
xcrun stapler staple "/Users/runner/work/QLog/QLog/build/qlog.app"
xcrun stapler validate "/Users/runner/work/QLog/QLog/build/qlog.app"
- name: make dmg
run: |
set -euo pipefail
# use TAGVERSION, but make a nicer filename (strip the "-14-g...." if you want)
VERSION="${TAGVERSION%%-*}" # => "0.47.1" from "0.47.1-14-g0022e427"
DMG_NAME="QLog.v${VERSION}.dmg"
echo "DMG_NAME=$DMG_NAME" >> "$GITHUB_ENV"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
mkdir -p out
cp -R "/Users/runner/work/QLog/QLog/build/qlog.app" out/
ln -s /Applications out/Applications
hdiutil create \
-volname "QLog Installer" \
-srcfolder out \
-ov -format UDZO \
"/Users/runner/work/QLog/QLog/build/$DMG_NAME"
ls -lh "/Users/runner/work/QLog/QLog/build/$DMG_NAME"
- name: Codesign dmg bundle
env:
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
run: |
set -euo pipefail
DMG="$GITHUB_WORKSPACE/build/$DMG_NAME"
test -f "$DMG"
KEYCHAIN="$RUNNER_TEMP/build.keychain-db"
# If the prior step already created/imported, this will work as-is.
# But on Actions, each step is a new shell: re-create+import to be safe.
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" "$KEYCHAIN" || true
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" "$KEYCHAIN"
security list-keychains -d user -s "$KEYCHAIN"
security default-keychain -d user -s "$KEYCHAIN"
echo "$MACOS_CERTIFICATE" | base64 --decode > "$RUNNER_TEMP/cert.p12"
security import "$RUNNER_TEMP/cert.p12" \
-k "$KEYCHAIN" \
-P "$MACOS_CERTIFICATE_PWD" \
-T /usr/bin/codesign \
-T /usr/bin/security || true
security set-key-partition-list -S apple-tool:,apple:,codesign: \
-s -k "$MACOS_CI_KEYCHAIN_PWD" "$KEYCHAIN"
SIGN_ID_SHA=$(security find-identity -v -p codesigning "$KEYCHAIN" \
| awk '/Developer ID Application/ {print $2; exit}')
if [[ -z "${SIGN_ID_SHA:-}" ]]; then
echo "ERROR: No Developer ID Application identity found in keychain."
exit 1
fi
/usr/bin/codesign --force --timestamp -s "$SIGN_ID_SHA" "$DMG"
/usr/bin/codesign -v --verbose=4 "$DMG"
- name: Notarize dmg
env:
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
run: |
set -euo pipefail
DMG="/Users/runner/work/QLog/QLog/build/$DMG_NAME"
test -f "$DMG"
xcrun notarytool store-credentials "notarytool-profile" \
--apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" \
--team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" \
--password "$PROD_MACOS_NOTARIZATION_PWD"
ditto -c -k "$DMG" "notarization.zip"
xcrun notarytool submit "notarization.zip" \
--keychain-profile "notarytool-profile" \
--wait --output-format json > notarization_dmg.json
cat notarization_dmg.json
NOTARY_ID=$(python3 -c 'import json; print(json.load(open("notarization_dmg.json"))["id"])')
xcrun notarytool log "$NOTARY_ID" --keychain-profile "notarytool-profile" || true
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
- name: Copy artifact
uses: actions/upload-artifact@v4
with:
name: QLog-${{ env.TAGVERSION }}-macos
path: /Users/runner/work/QLog/QLog/build/${{ env.DMG_NAME }}