Skip to content

refactor: electron-builder configuration #1917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions config/electron-builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const { Configuration } = require('electron-builder');

/**
* @type {Configuration}
*/
const config = {
productName: 'Gitify',
appId: 'com.electron.gitify',
copyright: 'Copyright © 2025 Gitify Team',
asar: true,
files: [
'assets/images/*',
'assets/sounds/*',
'build/**/*',
'LICENSE',
'node_modules/**/*',
'package.json',
],
electronLanguages: ['en'],
protocols: [
{
name: 'Gitify',
schemes: ['gitify', 'gitify-dev'],
},
],
mac: {
category: 'public.app-category.developer-tools',
icon: 'assets/images/app-icon.icns',
identity: 'Adam Setch (5KD23H9729)',
type: 'distribution',
notarize: false,
target: {
target: 'default',
arch: ['universal'],
},
hardenedRuntime: true,
entitlements: 'assets/entitlements.mac.plist',
entitlementsInherit: 'assets/entitlements.mac.plist',
gatekeeperAssess: false,
extendInfo: {
NSBluetoothAlwaysUsageDescription: null,
NSBluetoothPeripheralUsageDescription: null,
NSCameraUsageDescription: null,
NSMicrophoneUsageDescription: null,
},
},
dmg: {
icon: 'assets/images/app-icon.icns',
sign: false,
},
win: {
target: 'nsis',
icon: 'assets/images/app-icon.ico',
},
nsis: {
oneClick: false,
},
linux: {
target: ['AppImage', 'deb', 'rpm'],
category: 'Development',
maintainer: 'Gitify Team',
},
publish: {
provider: 'github',
owner: 'gitify-app',
repo: 'gitify',
},
afterSign: 'scripts/afterSign.js',
afterPack: 'scripts/afterPack.js',
};

module.exports = config;
71 changes: 3 additions & 68 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"watch:main": "webpack --watch --config ./config/webpack.config.main.base.ts",
"watch:renderer": "webpack --watch --config ./config/webpack.config.renderer.base.ts",
"prepare:remove-source-maps": "ts-node ./scripts/delete-source-maps.ts",
"package:linux": "electron-builder --linux",
"package:macos": "electron-builder --mac",
"package:win": "electron-builder --win",
"package:linux": "electron-builder --linux --config ./config/electron-builder.js",
"package:macos": "electron-builder --mac --config ./config/electron-builder.js",
"package:win": "electron-builder --win --config ./config/electron-builder.js",
"lint:check": "biome check",
"lint": "biome check --fix",
"test": "jest",
Expand Down Expand Up @@ -66,71 +66,6 @@
"url": "https://github.com/gitify-app/gitify/issues"
},
"homepage": "https://gitify.io/",
"build": {
"productName": "Gitify",
"appId": "com.electron.gitify",
"copyright": "Copyright © 2025 Gitify Team",
"asar": true,
"files": [
"assets/images/*",
"assets/sounds/*",
"build/**/*",
"LICENSE",
"node_modules/**/*",
"package.json"
],
"electronLanguages": ["en"],
"protocols": [
{
"name": "Gitify",
"schemes": ["gitify", "gitify-dev"]
}
],
"mac": {
"category": "public.app-category.developer-tools",
"icon": "assets/images/app-icon.icns",
"identity": "Adam Setch (5KD23H9729)",
"type": "distribution",
"notarize": false,
"target": {
"target": "default",
"arch": ["universal"]
},
"hardenedRuntime": true,
"entitlements": "assets/entitlements.mac.plist",
"entitlementsInherit": "assets/entitlements.mac.plist",
"gatekeeperAssess": false,
"extendInfo": {
"NSBluetoothAlwaysUsageDescription": null,
"NSBluetoothPeripheralUsageDescription": null,
"NSCameraUsageDescription": null,
"NSMicrophoneUsageDescription": null
}
},
"dmg": {
"icon": "assets/images/app-icon.icns",
"sign": false
},
"win": {
"target": "nsis",
"icon": "assets/images/app-icon.ico"
},
"nsis": {
"oneClick": false
},
"linux": {
"target": ["AppImage", "deb", "rpm"],
"category": "Development",
"maintainer": "Gitify Team"
},
"publish": {
"provider": "github",
"owner": "gitify-app",
"repo": "gitify"
},
"afterSign": "scripts/notarize.js",
"afterPack": "scripts/afterPack.js"
},
"dependencies": {
"@electron/remote": "2.1.2",
"electron-log": "5.3.2",
Expand Down
18 changes: 10 additions & 8 deletions scripts/afterPack.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ const path = require('node:path');
const fs = require('node:fs');
const { AfterPackContext } = require('electron-builder');

const packageJson = require('../package.json');
const electronLanguages = packageJson.build.electronLanguages;
const builderConfig = require('../config/electron-builder');
const electronLanguages = builderConfig.electronLanguages;

function logAfterPackProgress(msg) {
// biome-ignore lint/suspicious/noConsoleLog: log notarizing progress
console.log(` • [afterPack]: ${msg}`);
}

/**
* @param {AfterPackContext} context
*/
const afterPack = async (context) => {
// biome-ignore lint/suspicious/noConsoleLog: disabled
console.log('[afterPack]: Starting...');
logAfterPackProgress('Starting...');

const appName = context.packager.appInfo.productFilename;
const appOutDir = context.appOutDir;
Expand All @@ -20,8 +24,7 @@ const afterPack = async (context) => {
removeUnusedLocales(appOutDir, appName);
}

// biome-ignore lint/suspicious/noConsoleLog: disabled
console.log('[afterPack]: Completed');
logAfterPackProgress('Completed');
};

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

const resourcesPath = path.join(
appOutDir,
Expand Down
52 changes: 52 additions & 0 deletions scripts/afterSign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { notarize } = require('@electron/notarize');
const { AfterPackContext } = require('electron-builder');

const builderConfig = require('../config/electron-builder');
const appBundleId = builderConfig.appId;

function logAfterSignProgress(msg) {
// biome-ignore lint/suspicious/noConsoleLog: log notarizing progress
console.log(` • [afterSign]: ${msg}`);
}

/**
* @param {AfterPackContext} context
*/
const afterSign = async (context) => {
logAfterSignProgress('Starting...');

const { appOutDir } = context;
const appName = context.packager.appInfo.productFilename;
const shouldNotarize = process.env.NOTARIZE === 'true';

if (!shouldNotarize) {
logAfterSignProgress(
'skipping notarize step as NOTARIZE env flag was not set',
);
return;
}

notarizeApp(appName, appOutDir);

logAfterSignProgress('Completed');
};

/**
* Notarizes the application
* @param {string} appOutDir
* @param {string} appName
*/
const notarizeApp = (appOutDir, appName) => {
logAfterSignProgress('notarizing app');

return notarize({
appBundleId,
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLE_ID_USERNAME,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_ID_TEAM_ID,
tool: 'notarytool',
});
};

module.exports = afterSign;
40 changes: 0 additions & 40 deletions scripts/notarize.js

This file was deleted.