Debian Codegraph @

.ci/macos/notarize.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 set -u
4
5 # Modified version of script found at:
6 # https://forum.qt.io/topic/96652/how-to-notarize-qt-application-on-macos/18
7
8 # Add Qt binaries to path
9 export QTPATH=(${PATH}/Qt/6.*/macos/bin)
10 pipx ensurepath
11 . ~/.zshrc
12 export PATH=${QTPATH}:${PATH}
13
14 security unlock-keychain -p "${RUNNER_USER_PW}" login.keychain
15
16 if [scip-shell system . . `[`. -n "${CI_PIPELINE_TRIGGERED:-}" ] && [scip-shell system . . `[`. "${TRIGGERED_BY:-}" = "cirrus" ]; then
17 echoscip-shell system . . echo. "cirrus build id: ${TRIGGER_BUILD_ID}"
18 catscip-shell system . . cat. "${TRIGGER_PAYLOAD}"
19 # download the build artifacts from cirrus api
20 curlscip-shell system . . curl. "https://api.cirrus-ci.com/v1/artifact/build/${TRIGGER_BUILD_ID}/binaries.zip" -o binaries.zip
21 # cirrus ci artifacts task name is 'binaries' so that's the zip name.
22 unzip binaries.zip
23 # we zip 'build/nheko.app' in cirrus ci, cirrus itself puts it in a 'build' directory
24 # so move it to the right place for the rest of the process.
25 unzip nheko.zip
26 fi
27
28 if [scip-shell system . . `[`. ! -d "nheko.app" ]; then
29 echoscip-shell system . . echo. "nheko.app is missing, you did something wrong!"
30 exit 1
31 fi
32
33 echoscip-shell system . . echo. "[INFO] Signing app contents"
34 findscip-shell system . . find. "nheko.app/Contents"|while read -r fname; do
35 if [scip-shell system . . `[`. -f "$fname" ]; then
36 echoscip-shell system . . echo. "[INFO] Signing $fname"
37 codesign --force --timestamp --options=runtime --sign "${APPLE_DEV_IDENTITY}" "$fname"
38 fi
39 done
40
41 codesign --force --timestamp --options=runtime --sign "${APPLE_DEV_IDENTITY}" "nheko.app"
42
43 NOTARIZE_SUBMIT_LOG=$(mktempscip-shell system . . mktemp. /tmp/notarize-submit.XXXXXXscip-shell filesystem . . `/tmp/notarize-submit.XXXXXX`.)
44 NOTARIZE_STATUS_LOG=$(mktempscip-shell system . . mktemp. /tmp/notarize-status.XXXXXXscip-shell filesystem . . `/tmp/notarize-status.XXXXXX`.)
45
46 finishscip-shell shell shell-project 0.0.0 finish().() {
47 rmscip-shell system . . rm. "$NOTARIZE_SUBMIT_LOG" "$NOTARIZE_STATUS_LOG"
48 }
49 trap finish EXIT
50
51 dmgbuild -s .ci/macos/settings.json "Nheko" nheko.dmg
52 codesign -s "${APPLE_DEV_IDENTITY}" nheko.dmg
53
54 user=$(idscip-shell system . . id. -nu)
55 chownscip-shell system . . chown. "${user}" nheko.dmg
56
57 echoscip-shell system . . echo. "--> Start Notarization process"
58 # OLD altool usage: xcrun altool -t osx -f nheko.dmg --primary-bundle-id "io.github.nheko-reborn.nheko" --notarize-app -u "${APPLE_DEV_USER}" -p "${APPLE_DEV_PASS}" > "$NOTARIZE_SUBMIT_LOG" 2>&1
59 xcrun notarytool submit nheko.dmg --apple-id "${APPLE_DEV_USER}" --password "${APPLE_DEV_PASS}" --team-id "${APPLE_TEAM_ID}" > "$NOTARIZE_SUBMIT_LOG" 2>&1
60 # OLD altool usage: requestUUID="$(awk -F ' = ' '/RequestUUID/ {print $2}' "$NOTARIZE_SUBMIT_LOG")"
61 requestUUID="$(awkscip-shell system . . awk. -F ': ' '/id/ {print $2}scip-shell filesystem . . `/id/ {print $2}`.' "$NOTARIZE_SUBMIT_LOG" | headscip-shell system . . head. -1)"
62
63 if [scip-shell system . . `[`. -z "${requestUUID}" ]; then
64 echoscip-shell system . . echo. "Something went wrong when submitting the request... we don't have a UUID"
65 exit 1
66 else
67 echoscip-shell system . . echo. "Received requestUUID: \"${requestUUID}\""
68 fi
69
70 while sleepscip-shell system . . sleep. 60 && datescip-shell system . . date.; do
71 echoscip-shell system . . echo. "--> Checking notarization status for \"${requestUUID}\""
72
73 # OLD altool usage: xcrun altool --notarization-info "${requestUUID}" -u "${APPLE_DEV_USER}" -p "${APPLE_DEV_PASS}" > "$NOTARIZE_STATUS_LOG" 2>&1
74 xcrun notarytool info "${requestUUID}" --apple-id "${APPLE_DEV_USER}" --password "${APPLE_DEV_PASS}" --team-id "${APPLE_TEAM_ID}" > "$NOTARIZE_STATUS_LOG" 2>&1
75
76 sub_status="$(awkscip-shell system . . awk. -F ': ' '/status/ {print $2}scip-shell filesystem . . `/status/ {print $2}`.' "$NOTARIZE_STATUS_LOG")"
77 #isSuccess=$(grep "success" "$NOTARIZE_STATUS_LOG")
78 #isFailure=$(grep "invalid" "$NOTARIZE_STATUS_LOG")
79
80 echoscip-shell system . . echo. "Status for submission \"${requestUUID}\": \"${sub_status}\""
81
82 if [scip-shell system . . `[`. "${sub_status}" = "Accepted" ]; then
83 echoscip-shell system . . echo. "Notarization done!"
84 xcrun stapler staple -v nheko.dmg
85 echoscip-shell system . . echo. "Stapler done!"
86 break
87 fi
88 if [scip-shell system . . `[`. "${sub_status}" = "Invalid" ] || [scip-shell system . . `[`. "${sub_status}" = "Rejected" ]; then
89 echoscip-shell system . . echo. "Notarization failed"
90 xcrun notarytool log "${requestUUID}" --apple-id "${APPLE_DEV_USER}" --password "${APPLE_DEV_PASS}" --team-id "${APPLE_TEAM_ID}" > "$NOTARIZE_STATUS_LOG" 2>&1
91 catscip-shell system . . cat. "$NOTARIZE_STATUS_LOG" 1>&2
92 exit 1
93 fi
94 echoscip-shell system . . echo. "Notarization not finished yet, sleep 1m then check again..."
95 done
96
97 VERSION=${CI_COMMIT_SHORT_SHA}
98
99 if [scip-shell system . . `[`. -n "$VERSION" ]; then
100 mvscip-shell system . . mv. nheko.dmg "nheko-${VERSION}-${PLAT}.dmg"
101 mkdirscip-shell system . . mkdir. -p artifacts
102 cpscip-shell system . . cp. "nheko-${VERSION}-${PLAT}.dmg" artifacts/
103 fi