mac-notarise.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const { notarize } = require("@electron/notarize");
  2. // https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/
  3. /**
  4. * @param {import("electron-builder").AfterPackContext} ctx
  5. */
  6. exports.default = async function notarizing(ctx) {
  7. if (ctx.electronPlatformName !== "darwin") return;
  8. const appleId = process.env.APPLEID;
  9. const appleIdPassword = process.env.APPLEID_PASSWORD;
  10. const teamId = process.env.TEAM_ID;
  11. const appname = ctx.packager.appInfo.productFilename;
  12. if (!appleId || !appleIdPassword) {
  13. console.error("environment variables APPLEID and APPLEID_PASSWORD are not both present, skipping notarisation");
  14. return;
  15. }
  16. /** @type {Parameters<typeof notarize>[0]} */
  17. let notarise_args = {
  18. appBundleId: "dev.pulsar-edit.pulsar",
  19. appPath: `${ctx.appOutDir}/${appname}.app`,
  20. appleId,
  21. appleIdPassword
  22. };
  23. if (!teamId) {
  24. console.log("no TEAM_ID, using (legacy) altool");
  25. notarise_args = {
  26. ...notarise_args,
  27. tool: "legacy"
  28. }
  29. } else {
  30. console.log("using notarytool");
  31. notarise_args = {
  32. ...notarise_args,
  33. tool: "notarytool",
  34. teamId
  35. };
  36. }
  37. require("debug").enable("electron-notarize");
  38. return await notarize(notarise_args);
  39. }