-
Notifications
You must be signed in to change notification settings - Fork 8
141 lines (118 loc) · 4.62 KB
/
Copy pathnotarize-macos.yml
File metadata and controls
141 lines (118 loc) · 4.62 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
name: Notarize macOS (Manual)
on:
workflow_dispatch:
inputs:
run_id:
description: "Build workflow run ID to pull artifacts from (optional)"
required: false
type: string
artifact_name:
description: "Artifact name from build workflow"
required: false
default: "roopik-macos-arm64"
type: string
branch:
description: "Branch to pull artifacts from when run_id is empty"
required: false
default: "develop"
type: string
jobs:
notarize-macos-arm64:
name: Notarize macOS (ARM64)
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Download signed artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: build-macos.yml
run_id: ${{ inputs.run_id }}
branch: ${{ inputs.branch }}
name: ${{ inputs.artifact_name }}
workflow_conclusion: success
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Notarize and staple
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
run: |
SIGNED_ZIP="$(find . -name 'Roopik-macos-signed.zip' -print -quit)"
if [ -z "$SIGNED_ZIP" ]; then
APP_PATH="$(find . -maxdepth 3 -name "*.app" -print -quit)"
if [ -z "$APP_PATH" ]; then
echo "Signed zip not found and no .app found in downloaded artifacts."
find . -maxdepth 4 -type f -name "*.zip" -print
exit 1
fi
mkdir -p .artifacts
SIGNED_ZIP=".artifacts/Roopik-macos-signed.zip"
ditto -c -k --sequesterRsrc --keepParent "$APP_PATH" "$SIGNED_ZIP"
fi
rm -rf .notarize
mkdir -p .notarize
ditto -x -k "$SIGNED_ZIP" .notarize
APP_PATH="$(find .notarize -maxdepth 3 -name "*.app" -print -quit)"
if [ -z "$APP_PATH" ]; then
echo "No .app found in notarize payload"
exit 1
fi
DMG_ROOT=".dmgroot"
DMG_NAME="Roopik-macos.dmg"
rm -rf "$DMG_ROOT"
mkdir -p "$DMG_ROOT"
cp -R "$APP_PATH" "$DMG_ROOT/"
ln -s /Applications "$DMG_ROOT/Applications"
rm -f "$DMG_NAME"
hdiutil detach "/Volumes/Roopik" -force || true
hdiutil create -volname "Roopik" -srcfolder "$DMG_ROOT" -ov -format UDZO "$DMG_NAME"
SUBMIT_JSON="$(xcrun notarytool submit "$DMG_NAME" \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD" \
--output-format json)"
echo "$SUBMIT_JSON"
REQUEST_ID="$(echo "$SUBMIT_JSON" | /usr/bin/python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")"
echo "Notarization request id: $REQUEST_ID"
MAX_ATTEMPTS=60
SLEEP_SECONDS=60
ATTEMPT=1
while [ "$ATTEMPT" -le "$MAX_ATTEMPTS" ]; do
LOG_JSON="$(xcrun notarytool log "$REQUEST_ID" \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD" \
--output-format json 2>/dev/null || true)"
STATUS="Pending"
if [ -n "$LOG_JSON" ] && [[ "$LOG_JSON" == \{* || "$LOG_JSON" == \[* ]]; then
STATUS="$(/usr/bin/python3 -c 'import json,sys; print(json.load(sys.stdin).get("status","Pending"))' <<<"$LOG_JSON")"
fi
echo "Notarization status ($ATTEMPT/$MAX_ATTEMPTS): $STATUS"
if [ "$STATUS" = "Accepted" ]; then
break
fi
if [ "$STATUS" = "Invalid" ]; then
echo "$LOG_JSON"
exit 1
fi
sleep "$SLEEP_SECONDS"
ATTEMPT=$((ATTEMPT + 1))
done
if [ "$STATUS" != "Accepted" ]; then
echo "Notarization did not finish in time. Request id: $REQUEST_ID"
exit 1
fi
xcrun stapler staple "$APP_PATH"
xcrun stapler staple "$DMG_NAME"
NOTARIZED_ZIP="./Roopik-macos-notarized.zip"
ditto -c -k --sequesterRsrc --keepParent "$APP_PATH" "$NOTARIZED_ZIP"
NOTARIZED_DMG="./Roopik-macos-notarized.dmg"
mv "$DMG_NAME" "$NOTARIZED_DMG"
- name: Upload notarized artifact (arm64)
uses: actions/upload-artifact@v4
with:
name: roopik-macos-arm64-notarized
path: |
Roopik-macos-notarized.zip
Roopik-macos-notarized.dmg
retention-days: 30