Last active
April 8, 2020 08:33
-
-
Save jlehikoinen/ce8858e328636c39a958bcf8b1a83395 to your computer and use it in GitHub Desktop.
Codesign macOS Installer package
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
# Automator > Quick Action | |
# Workflow receives current "files or folders" in "Finder" | |
# Add "Run Shell Script" action | |
# Copy script below to "Run Shell Script" window | |
# Replace <codesigning certificate> at row 28 with your certificate information | |
# Save quick action as: "Sign Installer package" | |
# Quick Actions live in: ~/Library/Services | |
# Receives files and folders | |
while read -r file; do | |
dest_dir="${file%/*}" | |
filename="${file##*/}" | |
filename="${filename%.*}" | |
ext="${file##*.}" | |
if [[ $ext != "pkg" ]]; then | |
/usr/bin/osascript -e "display alert \"Error: Only .pkg files supported\"" | |
exit 1 | |
fi | |
if [[ -f "$dest_dir"/"${filename}_signed.pkg" ]]; then | |
/usr/bin/osascript -e "display alert \"Error: Target file already exists\"" | |
exit 1 | |
fi | |
# Sign pkg using certificate found in keychain | |
/usr/bin/productsign --sign "Developer ID Installer: <codesigning certificate>" "$file" "$dest_dir"/"${filename}_signed.pkg" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment