Set up Signing and Notarizing for MacOS

This commit is contained in:
perf3ct
2025-02-22 22:43:09 +00:00
parent 2380d0af85
commit 226cf8dfd7
5 changed files with 270 additions and 30 deletions

View File

@@ -1,7 +1,7 @@
const path = require("path");
const fs = require("fs-extra");
const APP_NAME = "TriliumNext Notes";
const APP_NAME = "TriliumNextNotes";
const extraResourcesForPlatform = getExtraResourcesForPlatform();
const baseLinuxMakerConfigOptions = {
@@ -17,33 +17,37 @@ module.exports = {
overwrite: true,
asar: true,
icon: "./images/app-icons/icon",
osxSign: {},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID
},
extraResource: [
// Moved to root
...extraResourcesForPlatform,
// All resources should stay in Resources directory for macOS
...(process.platform === "darwin" ? [] : extraResourcesForPlatform),
// Moved to resources (TriliumNext Notes.app/Contents/Resources on macOS)
// These always go in Resources
"translations/",
"node_modules/@highlightjs/cdn-assets/styles"
],
afterComplete: [
(buildPath, _electronVersion, platform, _arch, callback) => {
for (const resource of extraResourcesForPlatform) {
const baseName = path.basename(resource);
// Only move resources on non-macOS platforms
if (platform !== "darwin") {
for (const resource of extraResourcesForPlatform) {
const baseName = path.basename(resource);
const sourcePath = path.join(buildPath, "resources", baseName);
const destPath = (baseName !== "256x256.png")
? path.join(buildPath, baseName)
: path.join(buildPath, "icon.png");
// prettier-ignore
const sourcePath = (platform === "darwin")
? path.join(buildPath, `${APP_NAME}.app`, "Contents", "Resources", baseName)
: path.join(buildPath, "resources", baseName);
// prettier-ignore
const destPath = (baseName !== "256x256.png")
? path.join(buildPath, baseName)
: path.join(buildPath, "icon.png");
// Copy files from resources folder to root
fs.move(sourcePath, destPath)
.then(() => callback())
.catch((err) => callback(err));
fs.move(sourcePath, destPath)
.then(() => callback())
.catch((err) => callback(err));
}
} else {
callback();
}
}
]