Skip to content

Commit e76aba7

Browse files
authored
refactor: electron-builder configuration (#1917)
* refactor: electron-builder configuration Signed-off-by: Adam Setch <[email protected]> * refactor: electron-builder configuration Signed-off-by: Adam Setch <[email protected]> * refactor: electron-builder configuration Signed-off-by: Adam Setch <[email protected]> --------- Signed-off-by: Adam Setch <[email protected]>
1 parent b6818e0 commit e76aba7

File tree

5 files changed

+137
-116
lines changed

5 files changed

+137
-116
lines changed

config/electron-builder.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const { Configuration } = require('electron-builder');
2+
3+
/**
4+
* @type {Configuration}
5+
*/
6+
const config = {
7+
productName: 'Gitify',
8+
appId: 'com.electron.gitify',
9+
copyright: 'Copyright © 2025 Gitify Team',
10+
asar: true,
11+
files: [
12+
'assets/images/*',
13+
'assets/sounds/*',
14+
'build/**/*',
15+
'LICENSE',
16+
'node_modules/**/*',
17+
'package.json',
18+
],
19+
electronLanguages: ['en'],
20+
protocols: [
21+
{
22+
name: 'Gitify',
23+
schemes: ['gitify', 'gitify-dev'],
24+
},
25+
],
26+
mac: {
27+
category: 'public.app-category.developer-tools',
28+
icon: 'assets/images/app-icon.icns',
29+
identity: 'Adam Setch (5KD23H9729)',
30+
type: 'distribution',
31+
notarize: false,
32+
target: {
33+
target: 'default',
34+
arch: ['universal'],
35+
},
36+
hardenedRuntime: true,
37+
entitlements: 'assets/entitlements.mac.plist',
38+
entitlementsInherit: 'assets/entitlements.mac.plist',
39+
gatekeeperAssess: false,
40+
extendInfo: {
41+
NSBluetoothAlwaysUsageDescription: null,
42+
NSBluetoothPeripheralUsageDescription: null,
43+
NSCameraUsageDescription: null,
44+
NSMicrophoneUsageDescription: null,
45+
},
46+
},
47+
dmg: {
48+
icon: 'assets/images/app-icon.icns',
49+
sign: false,
50+
},
51+
win: {
52+
target: 'nsis',
53+
icon: 'assets/images/app-icon.ico',
54+
},
55+
nsis: {
56+
oneClick: false,
57+
},
58+
linux: {
59+
target: ['AppImage', 'deb', 'rpm'],
60+
category: 'Development',
61+
maintainer: 'Gitify Team',
62+
},
63+
publish: {
64+
provider: 'github',
65+
owner: 'gitify-app',
66+
repo: 'gitify',
67+
},
68+
afterSign: 'scripts/afterSign.js',
69+
afterPack: 'scripts/afterPack.js',
70+
};
71+
72+
module.exports = config;

package.json

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"watch:main": "webpack --watch --config ./config/webpack.config.main.base.ts",
1313
"watch:renderer": "webpack --watch --config ./config/webpack.config.renderer.base.ts",
1414
"prepare:remove-source-maps": "ts-node ./scripts/delete-source-maps.ts",
15-
"package:linux": "electron-builder --linux",
16-
"package:macos": "electron-builder --mac",
17-
"package:win": "electron-builder --win",
15+
"package:linux": "electron-builder --linux --config ./config/electron-builder.js",
16+
"package:macos": "electron-builder --mac --config ./config/electron-builder.js",
17+
"package:win": "electron-builder --win --config ./config/electron-builder.js",
1818
"lint:check": "biome check",
1919
"lint": "biome check --fix",
2020
"test": "jest",
@@ -66,71 +66,6 @@
6666
"url": "https://github.com/gitify-app/gitify/issues"
6767
},
6868
"homepage": "https://gitify.io/",
69-
"build": {
70-
"productName": "Gitify",
71-
"appId": "com.electron.gitify",
72-
"copyright": "Copyright © 2025 Gitify Team",
73-
"asar": true,
74-
"files": [
75-
"assets/images/*",
76-
"assets/sounds/*",
77-
"build/**/*",
78-
"LICENSE",
79-
"node_modules/**/*",
80-
"package.json"
81-
],
82-
"electronLanguages": ["en"],
83-
"protocols": [
84-
{
85-
"name": "Gitify",
86-
"schemes": ["gitify", "gitify-dev"]
87-
}
88-
],
89-
"mac": {
90-
"category": "public.app-category.developer-tools",
91-
"icon": "assets/images/app-icon.icns",
92-
"identity": "Adam Setch (5KD23H9729)",
93-
"type": "distribution",
94-
"notarize": false,
95-
"target": {
96-
"target": "default",
97-
"arch": ["universal"]
98-
},
99-
"hardenedRuntime": true,
100-
"entitlements": "assets/entitlements.mac.plist",
101-
"entitlementsInherit": "assets/entitlements.mac.plist",
102-
"gatekeeperAssess": false,
103-
"extendInfo": {
104-
"NSBluetoothAlwaysUsageDescription": null,
105-
"NSBluetoothPeripheralUsageDescription": null,
106-
"NSCameraUsageDescription": null,
107-
"NSMicrophoneUsageDescription": null
108-
}
109-
},
110-
"dmg": {
111-
"icon": "assets/images/app-icon.icns",
112-
"sign": false
113-
},
114-
"win": {
115-
"target": "nsis",
116-
"icon": "assets/images/app-icon.ico"
117-
},
118-
"nsis": {
119-
"oneClick": false
120-
},
121-
"linux": {
122-
"target": ["AppImage", "deb", "rpm"],
123-
"category": "Development",
124-
"maintainer": "Gitify Team"
125-
},
126-
"publish": {
127-
"provider": "github",
128-
"owner": "gitify-app",
129-
"repo": "gitify"
130-
},
131-
"afterSign": "scripts/notarize.js",
132-
"afterPack": "scripts/afterPack.js"
133-
},
13469
"dependencies": {
13570
"@electron/remote": "2.1.2",
13671
"electron-log": "5.3.3",

scripts/afterPack.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ const path = require('node:path');
22
const fs = require('node:fs');
33
const { AfterPackContext } = require('electron-builder');
44

5-
const packageJson = require('../package.json');
6-
const electronLanguages = packageJson.build.electronLanguages;
5+
const builderConfig = require('../config/electron-builder');
6+
const electronLanguages = builderConfig.electronLanguages;
7+
8+
function logAfterPackProgress(msg) {
9+
// biome-ignore lint/suspicious/noConsoleLog: log notarizing progress
10+
console.log(` • [afterPack]: ${msg}`);
11+
}
712

813
/**
914
* @param {AfterPackContext} context
1015
*/
1116
const afterPack = async (context) => {
12-
// biome-ignore lint/suspicious/noConsoleLog: disabled
13-
console.log('[afterPack]: Starting...');
17+
logAfterPackProgress('Starting...');
1418

1519
const appName = context.packager.appInfo.productFilename;
1620
const appOutDir = context.appOutDir;
@@ -20,8 +24,7 @@ const afterPack = async (context) => {
2024
removeUnusedLocales(appOutDir, appName);
2125
}
2226

23-
// biome-ignore lint/suspicious/noConsoleLog: disabled
24-
console.log('[afterPack]: Completed');
27+
logAfterPackProgress('Completed');
2528
};
2629

2730
/**
@@ -30,8 +33,7 @@ const afterPack = async (context) => {
3033
* @param {string} appName
3134
*/
3235
const removeUnusedLocales = (appOutDir, appName) => {
33-
// biome-ignore lint/suspicious/noConsoleLog: disabled
34-
console.log('[afterPack]: removing unused locales');
36+
logAfterPackProgress('removing unused locales');
3537

3638
const resourcesPath = path.join(
3739
appOutDir,

scripts/afterSign.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { notarize } = require('@electron/notarize');
2+
const { AfterPackContext } = require('electron-builder');
3+
4+
const builderConfig = require('../config/electron-builder');
5+
const appBundleId = builderConfig.appId;
6+
7+
function logAfterSignProgress(msg) {
8+
// biome-ignore lint/suspicious/noConsoleLog: log notarizing progress
9+
console.log(` • [afterSign]: ${msg}`);
10+
}
11+
12+
/**
13+
* @param {AfterPackContext} context
14+
*/
15+
const afterSign = async (context) => {
16+
logAfterSignProgress('Starting...');
17+
18+
const { appOutDir } = context;
19+
const appName = context.packager.appInfo.productFilename;
20+
const shouldNotarize = process.env.NOTARIZE === 'true';
21+
22+
if (!shouldNotarize) {
23+
logAfterSignProgress(
24+
'skipping notarize step as NOTARIZE env flag was not set',
25+
);
26+
return;
27+
}
28+
29+
notarizeApp(appName, appOutDir);
30+
31+
logAfterSignProgress('Completed');
32+
};
33+
34+
/**
35+
* Notarizes the application
36+
* @param {string} appOutDir
37+
* @param {string} appName
38+
*/
39+
const notarizeApp = (appOutDir, appName) => {
40+
logAfterSignProgress('notarizing app');
41+
42+
return notarize({
43+
appBundleId,
44+
appPath: `${appOutDir}/${appName}.app`,
45+
appleId: process.env.APPLE_ID_USERNAME,
46+
appleIdPassword: process.env.APPLE_ID_PASSWORD,
47+
teamId: process.env.APPLE_ID_TEAM_ID,
48+
tool: 'notarytool',
49+
});
50+
};
51+
52+
module.exports = afterSign;

scripts/notarize.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)