diff --git a/build/macos/codeSign.js b/build/macos/codeSign.js new file mode 100644 index 000000000..e0d22597e --- /dev/null +++ b/build/macos/codeSign.js @@ -0,0 +1,36 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { execSync } = require("child_process"); +const { existsSync } = require("fs"); +const { join } = require("path"); + +/** + * @param {import("electron-builder").AfterPackContext} context + * @returns void + */ +const codeSign = (context) => { + const { appOutDir, packager } = context; + + const appName = packager.appInfo.productFilename; + const appPath = join(appOutDir, `${appName}.app`); + + if (!existsSync(appPath)) { + throw new Error(`App not found at path: ${appPath}`); + } + + console.log("Performing ad-hoc signing..."); + + try { + // Remove existing signature if any + execSync(`codesign --remove-signature "${appPath}"`, { stdio: "inherit" }); + + // Perform ad-hoc signing + execSync(`codesign --force --deep -s - "${appPath}"`, { stdio: "inherit" }); + + console.log("Ad-hoc signing completed successfully"); + } catch (error) { + console.error("Error during ad-hoc signing:", error.message); + throw error; + } +}; + +module.exports = codeSign; diff --git a/electron-builder.config.js b/electron-builder.config.js index 197682316..bfec2cc47 100644 --- a/electron-builder.config.js +++ b/electron-builder.config.js @@ -2,7 +2,7 @@ * @type {import('electron-builder').Configuration} * @see https://www.electron.build/configuration/configuration */ -module.exports = { +const baseConfig = { asar: true, asarUnpack: ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"], productName: "Ueli", @@ -14,27 +14,45 @@ module.exports = { extraMetadata: { version: process.env.VITE_APP_VERSION, }, - mac: { - category: "public.app-category.utilities", - icon: "assets/Build/app-icon-dark.png", - target: [{ target: "dmg" }, { target: "zip" }], - }, - win: { - icon: "assets/Build/app-icon-dark-transparent.png", - target: [{ target: "msi" }, { target: "nsis" }, { target: "zip" }, { target: "appx" }], +}; + +/** + * @type {Record} + */ +const platformSpecificConfig = { + darwin: { + ...baseConfig, + afterPack: "./build/macos/codeSign.js", + mac: { + category: "public.app-category.utilities", + icon: "assets/Build/app-icon-dark.png", + target: [{ target: "dmg" }, { target: "zip" }], + }, }, - appx: { - applicationId: "OliverSchwendener.Ueli", - backgroundColor: "#1F1F1F", - displayName: "Ueli", - identityName: "1915OliverSchwendener.Ueli", - publisher: "CN=AD6BF16D-50E3-4FD4-B769-78A606AFF75E", - publisherDisplayName: "Oliver Schwendener", - languages: ["en-US", "de-CH"], + win32: { + ...baseConfig, + appx: { + applicationId: "OliverSchwendener.Ueli", + backgroundColor: "#1F1F1F", + displayName: "Ueli", + identityName: "1915OliverSchwendener.Ueli", + publisher: "CN=AD6BF16D-50E3-4FD4-B769-78A606AFF75E", + publisherDisplayName: "Oliver Schwendener", + languages: ["en-US", "de-CH"], + }, + win: { + icon: "assets/Build/app-icon-dark-transparent.png", + target: [{ target: "msi" }, { target: "nsis" }, { target: "zip" }, { target: "appx" }], + }, }, linux: { - icon: "assets/Build/app-icon-dark.png", - category: "Utility", - target: [{ target: "AppImage" }, { target: "deb" }, { target: "zip" }], + ...baseConfig, + linux: { + icon: "assets/Build/app-icon-dark.png", + category: "Utility", + target: [{ target: "AppImage" }, { target: "deb" }, { target: "zip" }], + }, }, }; + +module.exports = platformSpecificConfig[process.platform];