support notarize with password or keychain

This commit is contained in:
Christopher Willis-Ford 2020-06-26 09:16:45 -07:00
parent 61251d111f
commit 000bff75ed

View file

@ -6,10 +6,10 @@ const notarizeMacBuild = async function (context) {
if (!process.env.AC_USERNAME) { if (!process.env.AC_USERNAME) {
console.error([ console.error([
'Notarizing the macOS build requires an Apple ID.', 'This build is not notarized and will not run on newer versions of macOS!',
'Please set the environment variable AC_USERNAME.', 'Notarizing the macOS build requires an Apple ID. To notarize future builds:',
'Make sure your keychain has an item for "Application Loader: your@apple.id"', '* Set the environment variable AC_USERNAME to your@apple.id and',
'This build will not run on newer versions of macOS!' '* Either set AC_PASSWORD or ensure your keychain has an item for "Application Loader: your@apple.id"'
].join('\n')); ].join('\n'));
return; return;
} }
@ -17,7 +17,11 @@ const notarizeMacBuild = async function (context) {
const appleId = process.env.AC_USERNAME; const appleId = process.env.AC_USERNAME;
const appleIdKeychainItem = `Application Loader: ${appleId}`; const appleIdKeychainItem = `Application Loader: ${appleId}`;
console.log(`Notarizing with Apple ID "${appleId}" and keychain item "${appleIdKeychainItem}"`); if (process.env.AC_PASSWORD) {
console.log(`Notarizing with Apple ID "${appleId}" and a password`);
} else {
console.log(`Notarizing with Apple ID "${appleId}" and keychain item "${appleIdKeychainItem}"`);
}
const {appOutDir} = context; const {appOutDir} = context;
const productFilename = context.packager.appInfo.productFilename; const productFilename = context.packager.appInfo.productFilename;
@ -25,7 +29,7 @@ const notarizeMacBuild = async function (context) {
appBundleId: appId, appBundleId: appId,
appPath: `${appOutDir}/${productFilename}.app`, appPath: `${appOutDir}/${productFilename}.app`,
appleId, appleId,
appleIdPassword: `@keychain:${appleIdKeychainItem}` appleIdPassword: process.env.AC_PASSWORD || `@keychain:${appleIdKeychainItem}`
}); });
}; };