From 197824004e7b99f15dff7d952dda9d6cf70f521e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Thu, 7 May 2020 17:37:39 +0200 Subject: [PATCH] notarize pkg --- build/mac/afterBuildHook.js | 16 ++++++++++++++++ build/mac/afterSignHook.js | 2 +- electron-builder.yml | 1 + scripts/build-macos.js | 8 ++++++-- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 build/mac/afterBuildHook.js diff --git a/build/mac/afterBuildHook.js b/build/mac/afterBuildHook.js new file mode 100644 index 00000000..ae04bd08 --- /dev/null +++ b/build/mac/afterBuildHook.js @@ -0,0 +1,16 @@ +const fs = require('fs') +const signHook = require('./afterSignHook') + +module.exports = async function (params) { + // notarize the app on Mac OS only. + if (process.platform !== 'darwin' || !process.env.GITHUB_REF || !process.env.GITHUB_REF.startsWith('refs/tags/')) { + return + } + console.log('afterBuild hook triggered') + + let pkgName = fs.readdirSync('dist').find(x => x.endsWith('.pkg')) + signHook({ + appOutDir: 'dist', + _pathOverride: pkgName, + }) +} diff --git a/build/mac/afterSignHook.js b/build/mac/afterSignHook.js index a937f575..3be474c3 100644 --- a/build/mac/afterSignHook.js +++ b/build/mac/afterSignHook.js @@ -13,7 +13,7 @@ module.exports = async function (params) { let appId = 'org.terminus' - let appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`) + let appPath = path.join(params.appOutDir, params._pathOverride || `${params.packager.appInfo.productFilename}.app`) if (!fs.existsSync(appPath)) { throw new Error(`Cannot find application at: ${appPath}`) } diff --git a/electron-builder.yml b/electron-builder.yml index c444c5ab..0ae82458 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -3,6 +3,7 @@ appId: org.terminus productName: Terminus compression: normal afterSign: "./build/mac/afterSignHook.js" +afterAllArtifactBuild: "./build/mac/afterBuildHook.js" files: - "**/*" - dist diff --git a/scripts/build-macos.js b/scripts/build-macos.js index ecc08471..e20206e4 100755 --- a/scripts/build-macos.js +++ b/scripts/build-macos.js @@ -1,9 +1,10 @@ #!/usr/bin/env node const builder = require('electron-builder').build const vars = require('./vars') +const fs = require('fs') +const signHook = require('../build/mac/afterSignHook') const isTag = (process.env.GITHUB_REF || '').startsWith('refs/tags/') -const isCI = !!process.env.GITHUB_REF builder({ dir: true, @@ -14,4 +15,7 @@ builder({ }, }, publish: isTag ? 'always' : 'onTag', -}).catch(() => process.exit(1)) +}).catch(e => { + console.error(e) + process.exit(1) +})