Description
- Electron-Builder Version:
^22.10.5
- Node Version:
v14.17.0
- Electron Version:
^11.0.1
- Electron Type (current, beta, nightly):
current
- Target:
dmg
Hey!
This issue is similar by description to #2317, but I have not found any answers there. I decided to open new issue and provide more background.
My application on Mac shows the following notification:
But once I close and reopen the app back nothing happens. The old version is still displayed. I also want my application use the quitAndInstall
pattern. For me the fact the the notification is displayed in the first place is strange.
The background:
- I have configured automatic updates for my application
- I have made my application notarized by apple
- I want to use
quitAndInstall
, I have ensure the safe exit - I am using Private GitHub repository to store releases
- Autoupdate on Linux AppImage works
How my application handles an update:
import { app, BrowserWindow, shell } from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
function ensureSafeQuitAndInstall() {
app.removeAllListeners('window-all-closed');
const browserWindows = BrowserWindow.getAllWindows();
browserWindows.forEach((browserWindow) => {
browserWindow.removeAllListeners('close');
});
autoUpdater.quitAndInstall(false);
}
export default class AppUpdater {
constructor() {
log.transports.file.level = 'info';
autoUpdater.logger = log;
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.on('update-downloaded', () => {
setImmediate(ensureSafeQuitAndInstall);
});
}
}
I took the code sample from this issue and built my implementation on top if it: #1604
Why I think the signature is fine:
Despite me expecting the signature with the Developer ID, the app only shows notarization and hardening. Not sure why. The app however, only promts the this on first install, thus I assume it is OK:
How I sign my app:
I used following configuration in package.json
:
...
"afterSign": ".erb/scripts/Notarize.js",
"mac": {
...
"target": [
"dmg"
],
"asarUnpack": "**/*.node",
"type": "distribution",
"hardenedRuntime" : true,
"gatekeeperAssess": false,
"entitlements": "assets/entitlements.mac.plist",
"entitlementsInherit": "assets/entitlements.mac.plist",
"icon": "assets/icons/mac/icon.icns",
"provisioningProfile": "assets/preflight_provision_profile.provisionprofile"
},
...
My notarization script is using electron-notarize
and I sign it with following code:
const { notarize } = require('electron-notarize');
const { build } = require('../../package.json');
exports.default = async function notarizeMacos(context) {
const { electronPlatformName, appOutDir } = context;
const appName = context.packager.appInfo.productFilename;
await notarize({
appBundleId: build.appId,
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASS,
ascProvider: process.env.APPLE_PROVIDER_ID,
});
};
I build my app using following command:
CSC_LINK="XXX" \
CSC_KEY_PASSWORD=XXX \
APPLE_ID="XXX" \
APPLE_ID_PASS="XXX" \
APPLE_PROVIDER_ID="XXX" \
yarn electron-builder build -mwl --publish always
What I also suspect:
The react boilerplate I use, contained the following code:
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
I heared that this could prevent app from closing. But I call app.removeAllListeners('window-all-closed')
thus this should not be the case.
In logs, I see following message (relating me to #486, but again, this appears to not break anything):
[XXX] [warn] Error: ditto: Couldn't read PKZip signature
[XXX] [error] Error: Error: ditto: Couldn't read PKZip signature
Any ideas, suggestions?