From 851ba29cd509ff46ef2196447a03e8ad69c95ce1 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Thu, 11 Apr 2024 15:54:39 +0200 Subject: [PATCH] feat: build for arm64 on MacOS Closes #1996 Closes #4236 --- .github/workflows/NIGHTLY.yml | 6 +- electron-builder.json | 12 +++- tasks/after-all-artifact-build.js | 28 -------- .../after-all-artifact-build/build-mac-zip.js | 71 ------------------- tasks/distro.js | 5 +- tasks/test-distro.js | 9 ++- 6 files changed, 22 insertions(+), 109 deletions(-) delete mode 100644 tasks/after-all-artifact-build.js delete mode 100644 tasks/after-all-artifact-build/build-mac-zip.js diff --git a/.github/workflows/NIGHTLY.yml b/.github/workflows/NIGHTLY.yml index 5812f84990..547b0e5315 100644 --- a/.github/workflows/NIGHTLY.yml +++ b/.github/workflows/NIGHTLY.yml @@ -12,8 +12,10 @@ jobs: - 'dist/camunda-modeler-nightly-linux-x64.tar.gz' - os: macos-12 files: - - 'dist/camunda-modeler-nightly-mac.dmg' - - 'dist/camunda-modeler-nightly-mac.zip' + - 'dist/camunda-modeler-nightly-mac-arm64.dmg' + - 'dist/camunda-modeler-nightly-mac-arm64.zip' + - 'dist/camunda-modeler-nightly-mac-x64.dmg' + - 'dist/camunda-modeler-nightly-mac-x64.zip' - os: windows-2022 files: - 'dist/camunda-modeler-nightly-win-ia32.zip' diff --git a/electron-builder.json b/electron-builder.json index 85fcdfba33..a01d6fbf52 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -13,7 +13,6 @@ ], "afterPack": "./tasks/after-pack.js", "afterSign": "./tasks/after-sign.js", - "afterAllArtifactBuild": "./tasks/after-all-artifact-build.js", "win": { "target": [ { @@ -34,7 +33,16 @@ "mac": { "hardenedRuntime": true, "entitlements": "./build/entitlements.mac.inherit.plist", - "target": "dmg" + "target": [ + { + "target": "dmg", + "arch": [ "x64", "arm64" ] + }, + { + "target": "zip", + "arch": [ "x64", "arm64" ] + } + ] }, "fileAssociations": [ { diff --git a/tasks/after-all-artifact-build.js b/tasks/after-all-artifact-build.js deleted file mode 100644 index 724b488b79..0000000000 --- a/tasks/after-all-artifact-build.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH - * under one or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information regarding copyright - * ownership. - * - * Camunda licenses this file to you under the MIT; you may not use this file - * except in compliance with the MIT License. - */ - -module.exports = async function(context) { - - const handlers = [ - require('./after-all-artifact-build/build-mac-zip') - ]; - - let result = []; - - for (const handler of handlers) { - const additionalArtifacts = await handler(context); - - if (additionalArtifacts) { - result = result.concat(...additionalArtifacts); - } - } - - return result; -}; diff --git a/tasks/after-all-artifact-build/build-mac-zip.js b/tasks/after-all-artifact-build/build-mac-zip.js deleted file mode 100644 index ca5a258ce1..0000000000 --- a/tasks/after-all-artifact-build/build-mac-zip.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH - * under one or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information regarding copyright - * ownership. - * - * Camunda licenses this file to you under the MIT; you may not use this file - * except in compliance with the MIT License. - */ - -const exec = require('execa').sync; - -const del = require('del').sync; - -const path = require('path'); - -/** - * Build zip artifact for MacOS since electron-builder breaks zips - * - * @param {import('electron-builder').BuildResult} context - * - * @return {Promise} - */ -module.exports = async function(context) { - - if (!isBuildingMacDistro(context)) { - return; - } - - const { - artifactPaths, - configuration, - outDir - } = context; - - const { - productName - } = configuration; - - const dmgPath = artifactPaths.find(path => /\.dmg$/.test(path)); - const zipPath = dmgPath.replace(/dmg$/, 'zip'); - - const appDir = path.join(outDir, 'mac'); - - console.log(` • building target=ZIP arch=x64 file=${zipPath}`); - - del(zipPath); - - exec('zip', [ '--symlinks', '-r', zipPath, `${productName}.app` ], { cwd: appDir }); - - // TODO: update dist/latest-mac.yml with blockmap information - // As of `electron-builder@22.1.0`, the `app-builder-bin` blockmap utility - // modifies the digested ZIP file and thus makes the central record directory broken. - - return [ zipPath ]; -}; - - -function isBuildingMacDistro(context) { - const { - platformToTargets - } = context; - - for (const platform of platformToTargets.keys()) { - if (platform.name === 'mac') { - return true; - } - } - - return false; -} diff --git a/tasks/distro.js b/tasks/distro.js index 17ffed0cb9..9517fba2d4 100644 --- a/tasks/distro.js +++ b/tasks/distro.js @@ -78,7 +78,6 @@ if (nightly) { const artifactOptions = [ '-c.artifactName=${name}-${version}-${os}-${arch}.${ext}', - '-c.dmg.artifactName=${name}-${version}-${os}.${ext}', '-c.nsis.artifactName=${name}-${version}-${os}-setup.${ext}', '-c.nsisWeb.artifactName=${name}-${version}-${os}-web-setup.${ext}', argv.compress === false && '-c.compression=store' @@ -105,12 +104,12 @@ if (certificateFingerprint) { signingOptions.push(`-c.win.certificateSha1=${certificateFingerprint}`); } -if (publish && (argv.ia32 || argv.x64)) { +if (publish && (argv.ia32 || argv.x64 || argv.arm64)) { console.error('Do not override arch; is manually pinned'); process.exit(1); } -const archOptions = [ 'x64', 'ia32' ].filter(a => argv[a]).map(a => `--${a}`); +const archOptions = [ 'x64', 'ia32', 'arm64' ].filter(a => argv[a]).map(a => `--${a}`); const extraMetadataOptions = [ `-c.extraMetadata.SENTRY_DSN=${ process.env.SENTRY_DSN || null }` diff --git a/tasks/test-distro.js b/tasks/test-distro.js index a00c62acab..98e44fc911 100644 --- a/tasks/test-distro.js +++ b/tasks/test-distro.js @@ -82,10 +82,13 @@ const expectedFiles = { } ], mac: [ - 'camunda-modeler-${version}-mac.dmg', { - name: 'camunda-modeler-${version}-mac.zip', - archs: [ 'x64' ], + name: 'camunda-modeler-${version}-mac-${arch}.dmg', + archs: [ 'x64', 'arm64' ] + }, + { + name: 'camunda-modeler-${version}-mac-${arch}.zip', + archs: [ 'x64', 'arm64' ], contents: [ 'Camunda Modeler.app/Contents/Info.plist' ]