From 38d0f307341a46dafc1aa2dde4f7d365e35632d7 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Sun, 3 Oct 2021 12:36:59 +0530 Subject: [PATCH] Support notarization on macOS --- .github/workflows/nodejs.yml | 2 ++ bin/notarize.js | 16 ++++++++++++++++ electron-builder.json | 1 + package.json | 1 + yarn.lock | 8 ++++++++ 5 files changed, 28 insertions(+) create mode 100644 bin/notarize.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 5256fbc4..9bbea1d8 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -47,6 +47,8 @@ jobs: CSC_KEY_PASSWORD: ${{ secrets.MAC_CERT_P12_PASSWORD }} WIN_CSC_LINK: ${{ secrets.WIN_CERT_P12_BASE64 }} WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_P12_PASSWORD }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} - name: Archive Build Artifacts uses: LabhanshAgrawal/upload-artifact@v3 with: diff --git a/bin/notarize.js b/bin/notarize.js new file mode 100644 index 00000000..f13093e5 --- /dev/null +++ b/bin/notarize.js @@ -0,0 +1,16 @@ +const { notarize } = require("electron-notarize"); + +exports.default = async function notarizing(context) { + const { electronPlatformName, appOutDir } = context; + if (electronPlatformName !== "darwin" || !process.env.APPLE_ID || !process.env.APPLE_PASSWORD) { + return; + } + + const appName = context.packager.appInfo.productFilename; + return await notarize({ + appBundleId: "co.zeit.hyper", + appPath: `${appOutDir}/${appName}.app`, + appleId: process.env.APPLE_ID, + appleIdPassword: process.env.APPLE_PASSWORD + }); +}; diff --git a/electron-builder.json b/electron-builder.json index 57923dd7..37dadbed 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -1,6 +1,7 @@ { "$schema": "http://json.schemastore.org/electron-builder", "appId": "co.zeit.hyper", + "afterSign": "./bin/notarize.js", "directories": { "app": "target" }, diff --git a/package.json b/package.json index 4364a3fe..3d360b5a 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,7 @@ "electron": "^13.2.3", "electron-builder": "^22.11.7", "electron-devtools-installer": "3.2.0", + "electron-notarize": "1.1.1", "electron-rebuild": "3.2.3", "electronmon": "^2.0.2", "eslint": "7.32.0", diff --git a/yarn.lock b/yarn.lock index 9a65dc90..d7f433f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3062,6 +3062,14 @@ electron-devtools-installer@3.2.0: tslib "^2.1.0" unzip-crx-3 "^0.2.0" +electron-notarize@1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.1.1.tgz#3ed274b36158c1beb1dbef14e7faf5927e028629" + integrity sha512-kufsnqh86CTX89AYNG3NCPoboqnku/+32RxeJ2+7A4Rbm4bbOx0Nc7XTy3/gAlBfpj9xPAxHfhZLOHgfi6cJVw== + dependencies: + debug "^4.1.1" + fs-extra "^9.0.1" + electron-publish@22.11.7: version "22.11.7" resolved "https://registry.npmjs.org/electron-publish/-/electron-publish-22.11.7.tgz#4126cbb08ccf082a2aa7fef89ee629b3a4b8ae9a"