question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish triggers afterAllArtifactBuild hook too late

See original GitHub issue
  • Version: 20.41.0
  • Target: Mac

I’m writing an afterAllArtifactBuild hook where the produced dmg on Mac is notarized using electron-notarize. This works fine when building (i.e. electron-builder build --mac): the hook triggers after all targets are built and the dmg is notarized.

When building and publishing to github by running electron-builder build --mac -p always however, electron-builder starts uploading the dmg to github even before the afterAllArtifactBuild hook is triggered.

When simply publishing without building, the afterAllArtifactBuild is not triggered at all!

Ideally the publish command should wait for the afterAllArtifactBuild hook to finish running, or not rebuild the targets at all. If publish did not rebuild the targets, one could notarize/generate checksums using the afterAllArtifactBuild hook then have the publish command only pickup the generated binaries; Now it overrides anything generated before!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
vcombeycommented, Jan 19, 2021

“Ideally the publish command should wait for the afterAllArtifactBuild hook to finish running !” I also think this should be the case. Is it the case ? I try to sign the exe on windows in afterAllArtifactBuild but the exe is upload before my script runs…

2reactions
dannicommented, Nov 27, 2019

Updated to add, you can work around this by setting publish: null on your pkg target, and then returning the path of the pkg in the afterAllArtifactBuild hook.

pkg:
  publish: null # This will be published by the afterAllArtifactBuild hook
/**
 * Notarize .pkg
 */
const fs = require('fs');

const notarize = require('electron-notarize');

module.exports = async function (context) {
  if (process.platform !== 'darwin') {
    console.log(`afterAllArtifactBuild: nothing to do on ${process.platform}`);
    return [];
  }

  const appBundleId = context.configuration.appId;
  const paths = await Promise.all(context.artifactPaths.map(async appPath => {
    if (!appPath.endsWith('.pkg')) return null;

    if (process.env.APPLE_ID === undefined) {
      console.warn("APPLE_ID not set, skipping notarization");
      return appPath;
    }

    console.log(`afterAllArtifactBuild: Notarizing ${appBundleId} at ${appPath}`);

    // Test we can access the file
    await fs.promises.access(appPath)
    await notarize.notarize({
      appBundleId,
      appPath,
      appleId: process.env.APPLE_ID,
      appleIdPassword: '@keychain:AC_PASSWORD',
    });

    return appPath;
  }));

  return paths.filter(appPath => appPath !== null);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

GitHub post-receive hook not triggered on Windows
I'm trying to use a post-receive git-hook to automate the deploy of a simple maven project by triggering a Jenkins pipeline I set...
Read more >
Common Configuration
afterAllArtifactBuild - The function (or path to file or module id) to be run after all artifacts are build. msiProjectCreated module:app-builder-lib/out/ ...
Read more >
Trigger Jenkins Build and Test with Git post-commit hook
Post Commit Hook setup in Git to trigger a job in JenkinsTrigger a Maven Build and JUnit Test Run when changes are committed...
Read more >
Configuring VCS Post-Commit Hooks for TeamCity
If too many VCS roots are matched by the request configured in the commit hook, it will lead to more requests and more...
Read more >
Deploy Hooks · Cloudflare Pages docs
With Deploy Hooks, you can trigger deployments using event sources ... will receive HTTP POST requests in order to initiate new deployments.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found