From 4c34077d46a3975d2e91ac8af2f54a3ee64028cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicola=CC=81s=20Lo=CC=81pez?= Date: Mon, 26 Aug 2024 11:31:59 -0400 Subject: [PATCH] signing --- .electron-builder.config.js | 108 +++++++++++++++++------------------ package.json | 2 +- scripts/.gitignore | 1 - scripts/notarize.js | 19 ------ signing/.gitignore | 6 ++ {scripts => signing}/sign.js | 11 ++-- 6 files changed, 66 insertions(+), 81 deletions(-) delete mode 100644 scripts/.gitignore delete mode 100644 scripts/notarize.js create mode 100644 signing/.gitignore rename {scripts => signing}/sign.js (85%) diff --git a/.electron-builder.config.js b/.electron-builder.config.js index a29f06c..e876ff7 100644 --- a/.electron-builder.config.js +++ b/.electron-builder.config.js @@ -2,59 +2,57 @@ * @type {() => import('electron-builder').Configuration} * @see https://www.electron.build/configuration/configurtagation */ - module.exports = async () => ({ - productName: "Justo Hub", - appId: "com.getjusto.Justo Hub", - // afterSign: './scripts/notarize.js', - directories: { - output: "dist", - buildResources: "build", - }, - publish: { - provider: "github", - publishAutoUpdate: true, - }, - mac: { - hardenedRuntime: true, - electronLanguages: ["en"], - icon: "build/icon.icns", - entitlements: - "./node_modules/electron-builder-notarize/entitlements.mac.inherit.plist", - publish: ["github"], - target: [ - { - target: "dmg", - arch: ["arm64", "x64"], - }, - { - target: "zip", - arch: ["arm64", "x64"], - }, - ], - notarize: { - teamId: process.env.APPLE_TEAM_ID, - }, - }, - win: { - publish: ["github"], - icon: "build/icon.ico", - signingHashAlgorithms: ["sha256"], - sign: "./scripts/sign.js", - artifactName: `Justo-Hub-Setup-v${process.env.npm_package_version}.exe`, - target: [ - { - target: "nsis", - arch: ["x64", "ia32"], - }, - ], - }, - nsis: { - oneClick: true, - perMachine: true, - }, - dmg: { - icon: "build/icon.icns", - internetEnabled: true, - }, -}); + productName: 'JustoHub', + appId: 'com.getjusto.crisp', + afterSign: 'electron-builder-notarize', + directories: { + output: 'dist', + buildResources: 'build', + }, + publish: { + provider: 'github', + publishAutoUpdate: true, + }, + mac: { + hardenedRuntime: true, + electronLanguages: ['en'], + icon: 'build/icon.icns', + entitlements: './node_modules/electron-builder-notarize/entitlements.mac.inherit.plist', + publish: ['github'], + target: [ + { + target: 'dmg', + arch: ['arm64', 'x64'], + }, + { + target: 'zip', + arch: ['arm64', 'x64'], + }, + ], + notarize: { + teamId: '3CZ24HA8DS', + }, + }, + win: { + publish: ['github'], + icon: 'build/icon.ico', + signingHashAlgorithms: ['sha256'], + sign: './signing/sign.js', + artifactName: `Justo-Hub-Setup-v${process.env.npm_package_version}.exe`, + target: [ + { + target: 'nsis', + arch: ['x64', 'ia32'], + }, + ], + }, + nsis: { + oneClick: true, + perMachine: true, + }, + dmg: { + icon: 'build/icon.icns', + internetEnabled: true, + }, +}) diff --git a/package.json b/package.json index 730aeb4..46b2a33 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "start": "yarn build && JUSTO_ENV=local electron ./compiled", "pack": "yarn build && electron-builder --config .electron-builder.config.js --dir", "build-win": "rm -rf ./dist && yarn build && electron-builder --config .electron-builder.config.js --win", - "release": "rm -rf ./dist && yarn build && electron-builder --config .electron-builder.config.js --win --mac" + "release": "rm -rf ./dist && yarn build && electron-builder --config .electron-builder.config.js --mac" }, "dependencies": { "body-parser": "^1.20.2", diff --git a/scripts/.gitignore b/scripts/.gitignore deleted file mode 100644 index 9d396b6..0000000 --- a/scripts/.gitignore +++ /dev/null @@ -1 +0,0 @@ -CodeSignTool-v1.3.0 \ No newline at end of file diff --git a/scripts/notarize.js b/scripts/notarize.js deleted file mode 100644 index 11ba8be..0000000 --- a/scripts/notarize.js +++ /dev/null @@ -1,19 +0,0 @@ -import {notarize} from '@electron/notarize' - -exports.default = async function notarizing(context) { - const {electronPlatformName, appOutDir} = context - if (electronPlatformName !== 'darwin') { - return - } - - const appName = context.packager.appInfo.productFilename - - // Package your app here, and code sign with hardened runtime - await notarize({ - appBundleId: 'com.getjusto.crisp', - appPath: `${appOutDir}/${appName}.app`, - appleId: process.env.APPLE_ID, - appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD, - teamId: process.env.APPLE_TEAM_ID - }) -} diff --git a/signing/.gitignore b/signing/.gitignore new file mode 100644 index 0000000..df45913 --- /dev/null +++ b/signing/.gitignore @@ -0,0 +1,6 @@ +cert.crt +cert.der +cert.p7b +release +justo spa +CodeSignTool-v1.3.0 \ No newline at end of file diff --git a/scripts/sign.js b/signing/sign.js similarity index 85% rename from scripts/sign.js rename to signing/sign.js index c6ca905..706cd68 100644 --- a/scripts/sign.js +++ b/signing/sign.js @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ const path = require('path') const fs = require('fs') const childProcess = require('child_process') @@ -24,20 +23,22 @@ function sign(configuration) { const {base, dir} = path.parse(configuration.path) const tempFile = path.join(TEMP_DIR, base) - const setDir = `cd ./scripts/CodeSignTool-v1.3.0` + const setDir = `cd ./signing/CodeSignTool-v1.3.0` const signFile = `sh ./CodeSignTool.sh sign -input_file_path="${configuration.path}" -output_dir_path="${TEMP_DIR}" -credential_id="${CREDENTIAL_ID}" -username="${USER_NAME}" -password="${USER_PASSWORD}" -totp_secret="${USER_TOTP}"` const moveFile = `mv "${tempFile}" "${dir}"` childProcess.execSync(`${setDir} && ${signFile} && ${moveFile}`, { - stdio: 'inherit' + stdio: 'inherit', }) } else { - console.warn(`sign.js - Can't sign file ${configuration.path}, missing value for: + console.warn(`sign.js - Can't sign file ${ + configuration.path + }, missing value for: ${USER_NAME ? '' : 'WINDOWS_SIGN_USER_NAME'} ${USER_PASSWORD ? '' : 'WINDOWS_SIGN_USER_PASSWORD'} ${CREDENTIAL_ID ? '' : 'WINDOWS_SIGN_CREDENTIAL_ID'} ${USER_TOTP ? '' : 'WINDOWS_SIGN_USER_TOTP'} `) - // process.exit(1) + process.exit(1) } }