Skip to content

Commit

Permalink
add notarization for mas build
Browse files Browse the repository at this point in the history
  • Loading branch information
praneetrohida committed Jun 8, 2022
1 parent 4016f48 commit 6bd9a23
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions scripts/after-sign-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,36 @@ module.exports = async function (params) {
return;
}

console.log('afterSign hook triggered with params:', params.targets);
console.log('afterSign hook triggered');

// Same appId in electron-builder.
let appId = 'chat.wip.menubar';

const notarizeAppAtPath = async (appPath) => {
const notarizeConfig = {
appBundleId: appId,
appPath: appPath,
appleApiKey: `${process.env.API_KEY_ID}`,
appleApiKeyId: process.env.API_KEY_ID,
appleApiIssuer: process.env.APPLE_ISSUER_ID,
};

await pRetry(
(attempt) => {
console.log('Notarization attempt: ', attempt);
return notarize(notarizeConfig);
},
{
retries: 5,
onFailedAttempt: (error) => {
console.log(
`Attempt ${error.attemptNumber} failed. There are ${error.retriesLeft} retries left.`,
);
},
},
);
};

let appPath = path.join(
appOutDir,
`${params.packager.appInfo.productFilename}.app`,
Expand All @@ -28,28 +53,11 @@ module.exports = async function (params) {

console.log(`Notarizing ${appId} found at ${appPath}`);

const notarizeConfig = {
appBundleId: appId,
appPath: appPath,
appleApiKey: `${process.env.API_KEY_ID}`,
appleApiKeyId: process.env.API_KEY_ID,
appleApiIssuer: process.env.APPLE_ISSUER_ID,
};
await notarizeAppAtPath(appPath);

await pRetry(
(attempt) => {
console.log('Notarization attempt: ', attempt);
return notarize(notarizeConfig);
},
{
retries: 5,
onFailedAttempt: (error) => {
console.log(
`Attempt ${error.attemptNumber} failed. There are ${error.retriesLeft} retries left.`,
);
},
},
);
console.log('Notarizing mas build');

await notarizeAppAtPath(appPath.replace('mac-universal', 'mas-universal'));

console.log(`Done notarizing ${appId}`);
};

0 comments on commit 6bd9a23

Please sign in to comment.