Skip to content

Commit 84b8f2a

Browse files
AndrewAndrew
authored andcommitted
Fix productsign hanging: unlock keychain before signing, add timeout
1 parent 079bc58 commit 84b8f2a

3 files changed

Lines changed: 1033 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,33 +314,86 @@ jobs:
314314
fi
315315
316316
echo "=== Signing macOS PKG ==="
317+
318+
# CRITICAL: Unlock keychain immediately before productsign
319+
# The keychain may have auto-locked since import step
320+
echo "Unlocking keychain..."
321+
security unlock-keychain -p "actions" temp.keychain
322+
security set-keychain-settings -lut 21600 temp.keychain
323+
324+
# Ensure temp.keychain is in search path and default
325+
security list-keychains -d user -s "$HOME/Library/Keychains/temp.keychain-db" "$HOME/Library/Keychains/login.keychain-db"
326+
security default-keychain -s temp.keychain
327+
317328
PKG=$(find dist -name "*.pkg" | head -n 1)
318329
319330
if [ -z "$PKG" ]; then
320331
echo "No PKG file found, checking for MAS build..."
321-
# For MAS builds, electron-builder creates the pkg differently
322332
PKG=$(find dist/mas -name "*.pkg" 2>/dev/null | head -n 1)
323333
fi
324334
335+
if [ -z "$PKG" ]; then
336+
PKG=$(find dist/mas-universal -name "*.pkg" 2>/dev/null | head -n 1)
337+
fi
338+
325339
if [ -n "$PKG" ]; then
326340
echo "Found PKG: $PKG"
341+
echo "PKG size: $(ls -lh "$PKG" | awk '{print $5}')"
327342
328343
# Find installer identity
329344
INSTALLER_IDENTITY=$(security find-identity -v temp.keychain 2>&1 | grep "3rd Party Mac Developer Installer\|Developer ID Installer" | head -1 | sed 's/.*"\(.*\)".*/\1/')
330345
331346
if [ -n "$INSTALLER_IDENTITY" ]; then
332347
echo "Signing with: $INSTALLER_IDENTITY"
333-
productsign --sign "$INSTALLER_IDENTITY" --keychain temp.keychain "$PKG" "${PKG%.pkg}-signed.pkg"
334-
mv "${PKG%.pkg}-signed.pkg" "$PKG"
335-
echo "✅ PKG signed successfully"
336348
337-
# Verify
338-
pkgutil --check-signature "$PKG" || true
349+
# Run productsign with timeout to prevent hanging (macOS compatible)
350+
# 5 minute timeout should be more than enough for any PKG
351+
(
352+
productsign --sign "$INSTALLER_IDENTITY" --keychain temp.keychain "$PKG" "${PKG%.pkg}-signed.pkg"
353+
) &
354+
SIGN_PID=$!
355+
356+
# Wait up to 300 seconds (5 minutes)
357+
TIMEOUT=300
358+
while [ $TIMEOUT -gt 0 ]; do
359+
if ! kill -0 $SIGN_PID 2>/dev/null; then
360+
# Process finished
361+
wait $SIGN_PID
362+
EXIT_CODE=$?
363+
break
364+
fi
365+
sleep 1
366+
TIMEOUT=$((TIMEOUT - 1))
367+
done
368+
369+
if [ $TIMEOUT -eq 0 ]; then
370+
echo "❌ productsign timed out after 5 minutes"
371+
kill -9 $SIGN_PID 2>/dev/null || true
372+
echo "This usually means keychain access is blocked."
373+
echo "Keychain info:"
374+
security list-keychains
375+
security default-keychain
376+
exit 1
377+
elif [ $EXIT_CODE -eq 0 ]; then
378+
mv "${PKG%.pkg}-signed.pkg" "$PKG"
379+
echo "✅ PKG signed successfully"
380+
381+
# Verify signature
382+
echo "Verifying signature..."
383+
pkgutil --check-signature "$PKG" || true
384+
else
385+
echo "❌ productsign failed with exit code $EXIT_CODE"
386+
exit 1
387+
fi
339388
else
340389
echo "⚠️ No installer signing identity found"
390+
echo "Available identities:"
391+
security find-identity -v temp.keychain
341392
fi
342393
else
343394
echo "No PKG file found to sign"
395+
echo "Contents of dist/:"
396+
find dist -type f -name "*.pkg" -o -name "*.app" 2>/dev/null || true
344397
fi
345398
346399
- name: Notarize macOS app

0 commit comments

Comments
 (0)