implemented --pkg and --notarize options

This commit is contained in:
Armin Briegel
2021-08-17 12:25:59 +02:00
parent af08a12d49
commit b38c49600f
2 changed files with 79 additions and 12 deletions

View File

@@ -1,5 +1,18 @@
#!/bin/zsh
# settings
# package
pkgname="Installomator"
identifier="com.scriptingosx.${pkgname}"
install_location="/usr/local/Installomator/"
signature="Developer ID Installer: Armin Briegel (JME5BW3F3R)"
# notarization
dev_team="JME5BW3F3R" # asc-provider
dev_account="developer@scriptingosx.com"
dev_keychain_label="notary-scriptingosx"
# parse arguments
zparseopts -D -E -a opts r -run s -script p -pkg n -notarize h -help -labels+:=label_args l+:=label_args
@@ -113,9 +126,61 @@ fi
if [[ $buildScript -eq 1 ]]; then
echo "# copying script to $repo_dir/Installomator.sh"
cp $destination_file $repo_dir/Installomator.sh
chmod 755 $repo_dir/Installomator.sh
fi
# TODO: build a pkg when flag is set
# build a pkg when flag is set
if [[ buildPkg -eq 1 ]]; then
echo "# building installer package"
tmpfolder=$(mktemp -d)
payloadfolder="${tmpfolder}/payload"
# TODO: notarize when flag is set
# create a projectfolder with a payload folder
if [[ ! -d "${payloadfolder}" ]]; then
mkdir -p "${payloadfolder}"
fi
# copy the script file
cp $repo_dir/Installomator.sh ${payloadfolder}
chmod 755 ${payloadfolder}/Installomator.sh
# set the DEBUG variable to 0
sed -i '' -e 's/^DEBUG=1$/DEBUG=0/g' ${payloadfolder}/Installomator.sh
# build the component package
pkgpath="${script_dir}/${pkgname}.pkg"
pkgbuild --root "${payloadfolder}" \
--identifier "${identifier}" \
--version "${version}" \
--install-location "${install_location}" \
"${pkgpath}"
# build the product archive
productpath="${repo_dir}/${pkgname}-${version}.pkg"
productbuild --package "${pkgpath}" \
--version "${version}" \
--identifier "${identifier}" \
--sign "${signature}" \
"${productpath}"
# clean up project folder
rm -Rf "${projectfolder}"
# clean the component pkgname
rm "$pkgpath"
fi
# notarize when flag is set
if [[ $notarizePkg -eq 1 ]]; then
# NOTE: notarytool requires Xcode 13
# upload for notarization
xcrun notarytool submit "$productpath" --keychain-profile "$dev_keychain_label" --wait
# staple result
echo "# Stapling $productpath"
xcrun stapler staple "$productpath"
fi