Skip to content

Commit

Permalink
fix: macos package signing build
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Feb 22, 2024
1 parent 8a3d41c commit ec7d3cc
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-nati
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
import { PublisherGithub } from '@electron-forge/publisher-github';
import fs from 'fs';
import path from 'path';
import { exec } from 'child_process';

import { mainConfig, mainDevConfig } from './webpack.main.config';
Expand All @@ -18,7 +17,7 @@ const config: ForgeConfig = {
packagerConfig: {
asar: true,
name: 'morpheus',
extraResource: ['./src/executables/'],
extraResource: ['./executables/'],
icon: 'src/frontend/assets/images/circle-mor-logo',
osxSign: {
identity: process.env.APPLE_DEVELOPER_ID,
Expand All @@ -31,40 +30,34 @@ const config: ForgeConfig = {
...(process.env.APPLE_ID &&
process.env.APPLE_ID_PASSWORD &&
process.env.APPLE_TEAM_ID && {
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
}),
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
}),
},
hooks: {
postPackage: async (_, { platform, outputPaths }) => {
prePackage: async (_, platform) => {
const platformFile =
platform === 'darwin'
? 'ollama-darwin'
: platform === 'win32'
? 'ollama.exe'
: 'ollama-linux';

const outputResourceFolder = `${outputPaths[0]}${platform === 'darwin' ? '/morpheus.app/Contents' : ''}/resources/executables/`;

fs.readdir(outputResourceFolder, (err, files) => {
if (err) {
throw err;
}
const filePath = `src/executables/${platformFile}`;

files.forEach((file) => {
const localPath = path.join(outputResourceFolder, file);
platform !== 'win32'
? exec(`chmod +x ${filePath}`)
: fs.chmodSync(filePath, 755);

if (file !== platformFile) {
//fs.unlinkSync(localPath);
} else {
platform !== 'win32' ? exec(`chmod +x ${localPath}`) : fs.chmodSync(localPath, 755);
}
});
});
fs.mkdirSync('executables');
fs.copyFileSync(filePath, `executables/${platformFile}`);
},
postPackage: async () => {
fs.rmSync('executables', { recursive: true, force: true });
}
},
rebuildConfig: {},
makers: [
Expand Down Expand Up @@ -94,14 +87,14 @@ const config: ForgeConfig = {
},
},
},
// contents: [
// {
// x: 410,
// y: 220,
// type: 'link',
// path: '/Applications',
// },
// ],
// contents: [
// {
// x: 410,
// y: 220,
// type: 'link',
// path: '/Applications',
// },
// ],
}),
],
publishers: [
Expand Down

0 comments on commit ec7d3cc

Please sign in to comment.