Skip to content

Commit

Permalink
refactor: update build config for signing binaries
Browse files Browse the repository at this point in the history
This commit updates the build configuration in the `build.js` file to include the signing of binaries for the macOS target. It adds a new function `binaries` that reads all files from the `electron/bins` directory and maps each file name to the path inside the `.app` bundle. The function is then used in the `mac` target configuration to include the binaries for signing. This change ensures that the binaries are properly signed during the build process.
  • Loading branch information
truemiller committed Sep 16, 2024
1 parent 61b87df commit a8049f0
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
require('dotenv').config();
const build = require('electron-builder').build;
const fs = require('fs');

const { publishOptions } = require('./electron/constants');

Expand All @@ -16,14 +17,16 @@ function artifactName() {
return prefix + '${productName}-${version}-${platform}-${arch}.${ext}';
}

const electronBinsDir = 'electron/bins';

const main = async () => {
console.log('Building...');

/** @type import {CliOptions} from "electron-builder" */
await build({
publish: 'onTag',
config: {
afterSign: 'electron/hooks/afterSign.js',
// afterSign: 'electron/hooks/afterSign.js',
appId: 'xyz.valory.olas-operate-app',
artifactName: artifactName(),
productName: 'Pearl',
Expand All @@ -33,7 +36,7 @@ const main = async () => {
},
extraResources: [
{
from: 'electron/bins',
from: electronBinsDir,
to: 'bins',
filter: ['**/*'],
},
Expand All @@ -42,22 +45,32 @@ const main = async () => {
to: '.env'
},
],
asar: true,
cscKeyPassword: process.env.CSC_KEY_PASSWORD,
cscLink: process.env.CSC_LINK,
mac: {
binaries: () => {
// Read all files from the 'electron/bins' directory
const binaries = fs.readdirSync(electronBinsDir);
// Map each file name to the path inside the .app bundle
return binaries.map(bin => {
console.log(`Included binary ${bin} for signing.`);
return `Contents/Resources/bins/${bin}`;
});
},
category: 'public.app-category.utilities',
entitlements: 'electron/entitlements.mac.plist',
entitlementsInherit: 'electron/entitlements.mac.plist',
target: [
{
target: 'dmg',
arch: ['arm64', "x64"],
},
],
publish: publishOptions,
category: 'public.app-category.utilities',
icon: 'electron/assets/icons/splash-robot-head-dock.png',
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: 'electron/entitlements.mac.plist',
entitlementsInherit: 'electron/entitlements.mac.plist',
notarize: {
teamId: process.env.APPLETEAMID,
},
Expand Down

0 comments on commit a8049f0

Please sign in to comment.