Skip to content

Commit

Permalink
Fix notarization issues after upgrading electron-builder to 24.13.3
Browse files Browse the repository at this point in the history
To fix issues with electron-builder and @electron/notarize this commit:
* Replaces old notarization code with built-in solution in
  electron-builder
* Moves notarization of pkg to build.sh
  • Loading branch information
raksooo committed Apr 24, 2024
1 parent a2230b4 commit 9a34650
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
12 changes: 12 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ if [[ "$SIGN" == "true" && "$(uname -s)" == "MINGW"* ]]; then
done
fi

# notarize installer on macOS
if [[ "$NOTARIZE" == "true" && "$(uname -s)" == "Darwin" ]]; then
log_info "Notarizing pkg"
xcrun notarytool submit dist/*"$PRODUCT_VERSION"*.pkg \
--keychain "$NOTARIZE_KEYCHAIN" \
--keychain-profile "$NOTARIZE_KEYCHAIN_PROFILE" \
--wait

log_info "Stapling pkg"
xcrun stapler staple dist/*"$PRODUCT_VERSION"*.pkg
fi

log_success "**********************************"
log_success ""
log_success " The build finished successfully! "
Expand Down
1 change: 0 additions & 1 deletion gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"nseventmonitor": "^1.0.4"
},
"devDependencies": {
"@electron/notarize": "^2.1.0",
"@playwright/test": "^1.41.1",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
Expand Down
22 changes: 1 addition & 21 deletions gui/tasks/distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const path = require('path');
const fs = require('fs');
const builder = require('electron-builder');
const { Arch } = require('electron-builder');
const { notarize } = require('@electron/notarize');
const { execFileSync } = require('child_process');

const noCompression = process.argv.includes('--no-compression');
Expand Down Expand Up @@ -88,6 +87,7 @@ const config = {
artifactName: 'MullvadVPN-${version}.${ext}',
category: 'public.app-category.tools',
icon: distAssets('icon-macos.icns'),
notarize: shouldNotarize,
extendInfo: {
LSUIElement: true,
NSUserNotificationAlertStyle: 'banner',
Expand Down Expand Up @@ -314,11 +314,6 @@ function packMac() {
return Promise.resolve();
},
afterAllArtifactBuild: async (buildResult) => {
if (shouldNotarize) {
// buildResult.artifactPaths[0] contains the path to the pkg.
await notarizeMac(buildResult.artifactPaths[0]);
}

// Remove the folder that contains the unpacked app. Electron builder cleans up some of
// these directories and it's changed between versions without a mention in the changelog.
for (const dir of appOutDirs) {
Expand All @@ -330,26 +325,11 @@ function packMac() {
afterSign: (context) => {
const appOutDir = context.appOutDir;
appOutDirs.push(appOutDir);

if (shouldNotarize) {
const appName = context.packager.appInfo.productFilename;
return notarizeMac(path.join(appOutDir, `${appName}.app`));
}
},
},
});
}

function notarizeMac(notarizePath) {
console.log('Notarizing ' + notarizePath);
return notarize({
appBundleId: config.appId,
appPath: notarizePath,
keychain: process.env.NOTARIZE_KEYCHAIN,
keychainProfile: process.env.NOTARIZE_KEYCHAIN_PROFILE,
});
}

function packLinux() {
if (noCompression) {
config.rpm.fpm.unshift('--rpm-compression', 'none');
Expand Down

0 comments on commit 9a34650

Please sign in to comment.