From 65aac4ae895e1244e30cb8ec4e014efbc25d4169 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Sun, 22 Nov 2026 19:21:22 -0600 Subject: [PATCH] fix(packaging): keep the macOS signing keychain after a successful import import-cert.sh deleted the temporary keychain on every exit, including success, so it was gone before package.sh signed with it in the next step. The v0.22.0 macOS release failed at the first codesign call with "The specified item could not be found in the keychain." The decoded certificate is still removed on every exit. The keychain and its folder are now removed only when the import fails; on success the release workflow's clean-up step deletes the keychain, as before #5923. This matches the shared import-macos-certificate action. --- packaging/macos/import-cert.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index de16f22d43..c07f524864 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -24,9 +24,19 @@ KEYCHAIN="$TMP/pdfcraft-signing.keychain-db" CERT="$TMP/pdfcraft-signing.p12" KC_PASS="${KEYCHAIN_PASSWORD:-$(openssl rand -hex 24)}" -# Every exit path removes the keychain and the folder holding it: the keychain keeps the signing -# identity, and each run makes a new folder under a temporary parent that can outlive the job. -trap 'rm -f "$CERT"; security delete-keychain "$KEYCHAIN" 2>/dev/null || true; rm -rf "$TMP"' EXIT +# The decoded bundle is removed on every exit. The keychain and its folder are kept on success, +# because package.sh signs with them in a later step (the release workflow's clean-up step deletes +# the keychain), and removed only when this script fails. +cleanup() { + local status=$? + rm -f "$CERT" + if [[ "$status" -ne 0 ]]; then + security delete-keychain "$KEYCHAIN" 2>/dev/null || true + rm -rf "$TMP" + fi + exit "$status" +} +trap cleanup EXIT printf '%s' "$APPLE_CERTIFICATE" | base64 --decode >"$CERT" security create-keychain -p "$KC_PASS" "$KEYCHAIN" security set-keychain-settings -lut 21600 "$KEYCHAIN"