Skip to content

Commit 7fc7e6e

Browse files
committed
package signing again
1 parent 273d53b commit 7fc7e6e

File tree

6 files changed

+83
-37
lines changed

6 files changed

+83
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ package
1313
.gitsecret/keys/random_seed
1414
!*.secret
1515
gather
16+
tag_message.txt

.gitsecret/paths/mapping.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
buildnotes.md:f40b30c2fcc3dd898720f3b4a5fe36b5f48bbdbc8322639cbe2e5c5ecb639993
1+
buildnotes.md:5cc23a769ac033f097cd36898a616de8fa6e8648146265d1afa666a7a392cd1f

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.1.11
2+
3+
#### FIXED
4+
5+
- PKG signing
6+
17
## 2.1.10
28

39
## 2.1.9

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Howzit banner image](https://cdn3.brettterpstra.com/uploads/2022/08/gatherheader-rb.webp)
44

55

6-
Current version: 2.1.10
6+
Current version: 2.1.11
77

88
This project is the successor to read2text, which was a Python based tool that used Arc90 Readability and html2text to convert web URLs to Markdown documents, ready to store in your notes. It takes its name from another of my similar projects that I've since retired. It was this, but with a GUI, and this is infinitely more scriptable and is designed to nestle into your favorite tools and projects.
99

Sources/gather/gather.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Foundation
55
import HTML2Text
66
import Readability
77
import Yams
8-
var VERSION = "2.1.10"
8+
var VERSION = "2.1.11"
99

1010
var acceptedAnswerOnly = false
1111
var disableReadability = false

scripts/package.sh

Lines changed: 73 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,59 +38,83 @@ notarizefile() { # $1: path to file to notarize, $2: identifier
3838
filepath=${1:?"need a filepath"}
3939
identifier=${2:?"need an identifier"}
4040

41-
# upload file
41+
# upload file and wait for completion
4242
echo "## uploading $filepath for notarization"
43-
requestUUID=$(xcrun notarytool submit --wait \
43+
SUBMIT_OUTPUT=$(xcrun notarytool submit --wait \
4444
--keychain-profile "$dev_keychain_label" \
45-
"$filepath" 2>&1 |
46-
awk '/ id:/ { print $NF; }' | tail -n 1)
45+
"$filepath" 2>&1)
4746

48-
echo "Notarization RequestUUID: $requestUUID"
47+
echo "$SUBMIT_OUTPUT"
48+
49+
# Extract the request UUID
50+
requestUUID=$(echo "$SUBMIT_OUTPUT" | awk '/ id:/ { print $NF; }' | tail -n 1)
4951

5052
if [[ $requestUUID == "" ]]; then
51-
echo "could not upload for notarization"
52-
exit 1
53+
echo "## Error: could not get notarization request UUID"
54+
return 1
5355
fi
5456

55-
# # wait for status to be not "in progress" any more
56-
# request_status="In Progress"
57-
58-
# while [[ "$request_status" == "In Progress" ]]; do
59-
# echo -n "waiting... "
60-
# sleep 10
61-
# request_status=$(requeststatus "$requestUUID")
62-
# echo "$request_status"
63-
# done
57+
echo "Notarization RequestUUID: $requestUUID"
6458

65-
# print status information
66-
xcrun notarytool info \
59+
# Get detailed status
60+
echo "## Checking notarization status..."
61+
STATUS_OUTPUT=$(xcrun notarytool info \
6762
--keychain-profile "$dev_keychain_label" \
68-
"$requestUUID"
69-
echo
63+
"$requestUUID" 2>&1)
7064

71-
# if [[ $request_status != "success" ]]; then
72-
# echo "## could not notarize $filepath"
73-
# exit 1
74-
# fi
65+
echo "$STATUS_OUTPUT"
7566

67+
# Extract status
68+
request_status=$(echo "$STATUS_OUTPUT" | awk -F ': ' '/status:/ { print $2; }' | head -1 | tr -d ' ')
69+
70+
if [[ "$request_status" == "Accepted" ]]; then
71+
echo "## ✓ Notarization succeeded!"
72+
return 0
73+
else
74+
echo "## ✗ Notarization failed with status: $request_status"
75+
echo "## Getting notarization logs..."
76+
xcrun notarytool log \
77+
--keychain-profile "$dev_keychain_label" \
78+
"$requestUUID" 2>&1 | head -50
79+
return 1
80+
fi
7681
}
7782

7883
# Build the binary
7984
xcrun swift build -c release --arch arm64 --arch x86_64
8085
bindir=$(xcrun swift build -c release --arch arm64 --arch x86_64 --show-bin-path)
8186

8287
# Determine signing identity for binary (allow override via environment variable)
83-
# Default to 3rd Party Mac Developer Application (for Mac App Store) or Developer ID Application (for direct distribution)
84-
APP_SIGNING_IDENTITY="${APP_SIGNING_IDENTITY:-3rd Party Mac Developer Application: Brett Terpstra (47TRS7H4BH)}"
88+
# Try Developer ID Application first (for notarization), fall back to 3rd Party Mac Developer Application
89+
if [ -z "$APP_SIGNING_IDENTITY" ]; then
90+
# Try Developer ID Application first
91+
if security find-identity -v -p codesigning | grep -q "Developer ID Application: Brett Terpstra (47TRS7H4BH)"; then
92+
APP_SIGNING_IDENTITY="Developer ID Application: Brett Terpstra (47TRS7H4BH)"
93+
else
94+
# Fall back to 3rd Party Mac Developer Application
95+
APP_SIGNING_IDENTITY="3rd Party Mac Developer Application: Brett Terpstra (47TRS7H4BH)"
96+
fi
97+
fi
8598

8699
# Initialize notarization flag - will be set based on PKG signing success
87100
SKIP_NOTARIZATION=true
88101

89102
# Check if the identity exists, if not use ad-hoc signing
90103
if security find-identity -v -p codesigning | grep -q "$APP_SIGNING_IDENTITY"; then
91104
echo "## Signing binary with: $APP_SIGNING_IDENTITY"
92-
codesign --force --verbose --sign "$APP_SIGNING_IDENTITY" -o runtime --timestamp $bindir/$executable
93-
codesign --verify -vvvv $bindir/$executable
105+
if codesign --force --verbose --sign "$APP_SIGNING_IDENTITY" -o runtime --timestamp $bindir/$executable 2>&1; then
106+
codesign --verify -vvvv $bindir/$executable
107+
# Check if we're using Developer ID Application (required for notarization)
108+
if [[ "$APP_SIGNING_IDENTITY" == *"Developer ID Application"* ]]; then
109+
echo "## ✓ Binary signed with Developer ID Application (ready for notarization)"
110+
else
111+
echo "## Note: Using 3rd Party certificate - notarization will be skipped"
112+
fi
113+
else
114+
echo "## Warning: Failed to sign with '$APP_SIGNING_IDENTITY', trying ad-hoc signing"
115+
codesign --force --verbose --sign "-" $bindir/$executable
116+
codesign --verify -vvvv $bindir/$executable
117+
fi
94118
else
95119
echo "## Warning: Identity '$APP_SIGNING_IDENTITY' not found, using ad-hoc signing for binary"
96120
codesign --force --verbose --sign "-" $bindir/$executable
@@ -117,7 +141,13 @@ if [ -n "$INSTALLER_SIGNATURE" ] && [ "$INSTALLER_SIGNATURE" != "-" ]; then
117141
"$pkgpath" 2>&1; then
118142
echo "## ✓ PKG signed successfully"
119143
# PKG is signed with Developer ID Installer, can be notarized
120-
SKIP_NOTARIZATION=false
144+
# BUT: Binary must also be signed with Developer ID Application for notarization to succeed
145+
if [[ "$APP_SIGNING_IDENTITY" == *"Developer ID Application"* ]]; then
146+
SKIP_NOTARIZATION=false
147+
else
148+
echo "## Note: Binary not signed with Developer ID Application - notarization will be skipped"
149+
SKIP_NOTARIZATION=true
150+
fi
121151
else
122152
PKG_BUILD_EXIT=$?
123153
echo "## Warning: Failed to sign with '$INSTALLER_SIGNATURE' (exit code: $PKG_BUILD_EXIT), building unsigned pkg"
@@ -143,11 +173,20 @@ if [ "$SKIP_NOTARIZATION" = "false" ]; then
143173
# upload for notarization
144174
echo "Path: $pkgpath"
145175
echo "Identifier $identifier"
146-
notarizefile "$pkgpath" "$identifier"
147-
148-
# staple result
149-
echo "## Stapling $pkgpath"
150-
xcrun stapler staple "$pkgpath"
176+
if notarizefile "$pkgpath" "$identifier"; then
177+
# Only staple if notarization succeeded
178+
echo "## Stapling $pkgpath"
179+
xcrun stapler staple "$pkgpath"
180+
if [ $? -eq 0 ]; then
181+
echo "## ✓ Package stapled successfully"
182+
else
183+
echo "## Warning: Stapling failed"
184+
fi
185+
else
186+
echo "## Error: Notarization failed, skipping stapling"
187+
echo "## The PKG is signed but not notarized. You may need to fix signing issues."
188+
exit 1
189+
fi
151190
else
152191
echo "## Skipping notarization (ad-hoc or unsigned build)"
153192
fi

0 commit comments

Comments
 (0)