From f60792f1a1fbc038980bb2fa80e44e78de357997 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 10 Oct 2019 23:26:05 -0400 Subject: [PATCH] notarize that ish --- build/afterSignHook.js | 36 ++++++++++++++++++++++++++++++++++++ electron-builder.json | 13 +++---------- package.json | 1 + yarn.lock | 10 +++++++++- 4 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 build/afterSignHook.js diff --git a/build/afterSignHook.js b/build/afterSignHook.js new file mode 100644 index 000000000..c155feed8 --- /dev/null +++ b/build/afterSignHook.js @@ -0,0 +1,36 @@ +// 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 = 'io.lbry.LBRY'; + + 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}`); +}; diff --git a/electron-builder.json b/electron-builder.json index 755411427..bd6826104 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -71,15 +71,7 @@ } }, "deb": { - "depends": [ - "gconf2", - "gconf-service", - "libnotify4", - "libappindicator1", - "libxtst6", - "libnss3", - "libsecret-1-0" - ] + "depends": ["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3", "libsecret-1-0"] }, "nsis": { "perMachine": true, @@ -94,5 +86,6 @@ } ] }, - "artifactName": "${productName}_${version}.${ext}" + "artifactName": "${productName}_${version}.${ext}", + "afterSign": "./build/afterSignHook.js" } diff --git a/package.json b/package.json index a9f518080..1a8b5af75 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "dependencies": { "electron-dl": "^1.11.0", "electron-log": "^2.2.12", + "electron-notarize": "^0.1.1", "electron-updater": "^4.1.2", "express": "^4.16.4", "if-env": "^1.0.4", diff --git a/yarn.lock b/yarn.lock index 408c0b2d4..3318de9e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3984,6 +3984,14 @@ electron-log@^2.2.12: resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.17.tgz#e71e2ebb949fc96ded7cdb99eeee7202e48981d2" integrity sha512-v+Af5W5z99ehhaLOfE9eTSXUwjzh2wFlQjz51dvkZ6ZIrET6OB/zAZPvsuwT6tm3t5x+M1r+Ed3U3xtPZYAyuQ== +electron-notarize@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-0.1.1.tgz#c3563d70c5e7b3315f44e8495b30050a8c408b91" + integrity sha512-TpKfJcz4LXl5jiGvZTs5fbEx+wUFXV5u8voeG5WCHWfY/cdgdD8lDZIZRqLVOtR3VO+drgJ9aiSHIO9TYn/fKg== + dependencies: + debug "^4.1.1" + fs-extra "^8.0.1" + electron-publish@21.2.0: version "21.2.0" resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-21.2.0.tgz#cc225cb46aa62e74b899f2f7299b396c9802387d" @@ -5126,7 +5134,7 @@ fs-extra@^7.0.0, fs-extra@^7.0.1: jsonfile "^4.0.0" universalify "^0.1.0" -fs-extra@^8.1.0: +fs-extra@^8.0.1, fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==