Skip to content

Instantly share code, notes, and snippets.

@martani
Created May 25, 2019 03:12
Show Gist options
  • Save martani/643a0b5593b86e1dae05f53b1814b0c6 to your computer and use it in GitHub Desktop.
Save martani/643a0b5593b86e1dae05f53b1814b0c6 to your computer and use it in GitHub Desktop.
electron-builder after sign hook to notarize Mac OS apps using electron-notarize
// See: https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db
const fs = require('fs');
const path = require('path');
var electron_notarize = require('electron-notarize');
module.exports = async function (params) {
// Only notarize the app on Mac OS only.
if (process.platform !== 'darwin') {
return;
}
console.log('afterSign hook triggered', params);
// Same appId in electron-builder.
let appId = '<Change this to your appId ad defined in your electron-builder config>'
let appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);
if (!fs.existsSync(appPath)) {
throw new Error(`Cannot find application at: ${appPath}`);
}
console.log(`Notarizing ${appId} found at ${appPath}`);
try {
await electron_notarize.notarize({
appBundleId: appId,
appPath: appPath,
appleId: process.env.appleId,
appleIdPassword: process.env.appleIdPassword,
});
} catch (error) {
console.error(error);
}
console.log(`Done notarizing ${appId}`);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment