Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to know if the app was signed in the afterSign hook #4452

Closed
cslecours opened this issue Nov 22, 2019 · 3 comments
Closed

No way to know if the app was signed in the afterSign hook #4452

cslecours opened this issue Nov 22, 2019 · 3 comments
Labels

Comments

@cslecours
Copy link

cslecours commented Nov 22, 2019

Which version of electron-builder are you using?

  • electron-updater: "4.2.0"

  • electron: "6.1.4"

  • electron-builder: "21.2.0"

  • electron-notarize: "0.2.0"

  • Target: MacOS Catalina

In the afterSign hook, there is no way to know if the app signing was successful or not. If it's not successful, I don't want to run the notarize process.

The info is not available in the packContext.

await this.signApp(packContext, isAsar)
const afterSign = resolveFunction(this.config.afterSign, "afterSign")
if (afterSign != null) {
await Promise.resolve(afterSign(packContext))
}

@kzimny
Copy link

kzimny commented Nov 23, 2019

When the notarization was not successful you should get an error in the console in catch block:

const fs = require('fs');
const path = require('path');
var electron_notarize = require('electron-notarize');

module.exports = async function (params) {
    // Only notarize the app on Mac OS only.
    if (process.platform !== 'darwin') {
        return;
    }
    console.log('afterSign hook triggered', params);

    // Same appId in electron-builder.
    let appId = 'org.mycompany.myapp'

    let appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);
    if (!fs.existsSync(appPath)) {
        throw new Error(`Cannot find application at: ${appPath}`);
    }

    console.log(`Notarizing ${appId} found at ${appPath}`);

    try {
        await electron_notarize.notarize({
            appBundleId: appId,
            appPath: appPath,
            appleId: 's',
            appleIdPassword: '',
        });
    } catch (error) {
        console.error(error);
    }

    console.log(`Done notarizing ${appId}`);
};

You right. But why your app should not be signed? When the certificate exist the app should be signed.

@stale
Copy link

stale bot commented Jan 22, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jan 22, 2020
@stale stale bot closed this as completed Jan 29, 2020
@rbenet-lbo
Copy link

I actually was trying also to achieve the same thing. Anybody has an answer by now ?

I don't always want to sign my app (eg. on some CI builds) and in those cases I cannot run 'notarize' flow, because it will fail.
Ideally the notarise script would only be called when the file was actually signed (not just after the sign phase). But I haven't figured out how to do that.
Second best, is that notarise script autodetect there was no signature and does not attempt to notarise the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants