-
Notifications
You must be signed in to change notification settings - Fork 1
fix: survive locked-keychain notarization and add RC resume path #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Shared /Applications deploy for release flows. | ||
| # | ||
| # The bundle is copied verbatim with ditto — never re-signed here. Re-signing | ||
| # after notarization changes the cdhash, which detaches the app from its | ||
| # notarization ticket and makes stapling the installed copy impossible | ||
| # (2026-07-30 RC incident). Both build-and-sign.sh and notarize-resume.sh must | ||
| # deploy the exact stapled dist bundle through this function. | ||
|
|
||
| kp_deploy_bundle_to_applications() { | ||
| local app_bundle=$1 | ||
| local app_name=$2 | ||
|
|
||
| # Stop running KeyPath and kanata BEFORE replacing the app bundle. | ||
| # Replacing binaries while the process is live causes macOS to detect | ||
| # code page mismatches and kill the process with: | ||
| # SIGKILL (Code Signature Invalid) / CODESIGNING / Invalid Page | ||
| # If kanata is killed mid-keystroke, the virtual HID holds the key down | ||
| # and the character repeats infinitely. | ||
| if pgrep -x "$app_name" > /dev/null; then | ||
| echo "🛑 Stopping running $app_name before deploy..." | ||
| killall "$app_name" 2>/dev/null || true | ||
|
|
||
| # Wait up to 5 seconds for graceful shutdown | ||
| local i | ||
| for i in {1..10}; do | ||
| if ! pgrep -x "$app_name" > /dev/null; then | ||
| break | ||
| fi | ||
| sleep 0.5 | ||
| done | ||
|
|
||
| # Force kill if still running | ||
| if pgrep -x "$app_name" > /dev/null; then | ||
| echo " ⚠️ Process still running, force killing..." | ||
| killall -9 "$app_name" 2>/dev/null || true | ||
| sleep 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Verify no KeyPath process remains | ||
| if pgrep -x "$app_name" > /dev/null; then | ||
| echo " ❌ ERROR: Failed to stop $app_name process" >&2 | ||
| echo " Please manually quit $app_name and run the deploy manually." >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| # Stop kanata so it doesn't get killed by the bundle replacement. | ||
| if pgrep -x "kanata" > /dev/null; then | ||
| echo "🛑 Stopping kanata service..." | ||
| local kanata_pid | ||
| kanata_pid=$(pgrep -x "kanata") | ||
| sudo kill "$kanata_pid" 2>/dev/null || true | ||
| sleep 1 | ||
| fi | ||
|
|
||
| echo "📂 Deploying to /Applications..." | ||
| local app_dest="/Applications/${app_name}.app" | ||
| rm -rf "$app_dest" | ||
| if ditto "$app_bundle" "$app_dest"; then | ||
| echo "✅ Deployed latest $app_name to $app_dest" | ||
| else | ||
| echo "⚠️ WARNING: Failed to copy $app_name to $app_dest" >&2 | ||
| echo "💡 TIP: You may need to manually copy $app_bundle to /Applications/" >&2 | ||
| fi | ||
|
|
||
| echo "🚪 Restarting app..." | ||
| echo " Starting new $app_name..." | ||
| open "$app_dest" | ||
|
|
||
| # Wait for new process to start and verify | ||
| sleep 2 | ||
| if pgrep -x "$app_name" > /dev/null; then | ||
| local new_pid | ||
| new_pid=$(pgrep -x "$app_name") | ||
| echo " ✅ $app_name restarted successfully (PID: $new_pid)" | ||
| else | ||
| echo " ⚠️ WARNING: $app_name may not have started. Run manually: open $app_dest" >&2 | ||
| fi | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
KP_NOTARY_AUTH=keychain-profileis set alongside an existingKP_NOTARY_KEY_PATH, this early return leaves the key path populated andkp_notary_resolve_authconsequently selects API-key authentication. Thus the documented force option cannot recover from a stale, inaccessible, or unwanted API key unless the caller also knows to unset the key variables; check the force setting before acceptingKP_NOTARY_KEY_PATH, or make the resolver honor it directly.Useful? React with 👍 / 👎.