Skip to content

Commit

Permalink
fix: use after artifact build for rename
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Sep 27, 2024
1 parent cde5bbb commit fa35020
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const main = async () => {
await build({
publish: 'onTag',
config: {
afterPack: './electron/scripts/afterPack.js',
afterAllArtifactBuild: './electron/scripts/afterPack.js',
appId: 'xyz.valory.olas-operate-app',
artifactName: artifactName(),
productName: 'Pearl',
Expand Down
13 changes: 6 additions & 7 deletions electron/scripts/afterPack.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
const builderUtil = require('builder-util');

/**
* @param {string} outDir - Output directory of the build
* @param {keyof typeof builderUtil.Arch} arch - CPU architecture
* @param {keyof typeof import('builder-util').Arch} arch - CPU architecture
*/
const renameLatestMacToArchSpecific = (outDir, arch) => {
console.log(`afterPack: renaming latest-mac.yml to latest-mac-${arch}.yml`);
Expand All @@ -17,17 +16,17 @@ const renameLatestMacToArchSpecific = (outDir, arch) => {

/**
* @note This function is called after the packaging of the app is done.
* @param {import('electron-builder').AfterPackContext} context - The context object from electron-builder
* @param {import('electron-builder').BuildResult} context - The context object from electron-builder
*/
const afterPack = async (context) => {
if (os.platform() === 'darwin') {
console.log('afterPack: macOS detected');

if (context.arch === builderUtil.Arch.x64) {
renameLatestMacToArchSpecific(context.appOutDir, 'x64');
if (process.env.ARCH === 'x64') {
renameLatestMacToArchSpecific(context.outDir, 'x64');
}
if (context.arch === builderUtil.Arch.arm64) {
renameLatestMacToArchSpecific(context.appOutDir, 'arm64');
if (process.env.ARCH === 'arm64') {
renameLatestMacToArchSpecific(context.outDir, 'arm64');
}
}
};
Expand Down

0 comments on commit fa35020

Please sign in to comment.