Skip to content

Commit

Permalink
added notarization for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
APPLE authored and APPLE committed Oct 8, 2020
1 parent c65d819 commit 5213904
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions electron-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = {
},
mac: {
target: ['dmg'],
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: 'build/entitlements.mac.plist',
entitlementsInherit: 'build/entitlements.mac.plist',
},
win: {
target: [
Expand All @@ -20,4 +24,5 @@ module.exports = {
},
],
},
afterSign: './notarize.js',
};
23 changes: 22 additions & 1 deletion electron/main/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {app, BrowserWindow, session} = require('electron');
const {app, BrowserWindow, session, Menu} = require('electron');
const path = require('path');
const isDevelopment = process.env.NODE_ENV === 'development';
const {format} = require('url');
Expand All @@ -12,6 +12,27 @@ if (require('electron-squirrel-startup')) {

let mainWindow;
const createWindow = () => {
let template = [];
const name = app.getName();
template.unshift({
label: name,
submenu: [
{
label: 'About ' + name,
role: 'about',
},
{
label: 'Quit',
accelerator: 'Command+Q',
click() {
app.quit();
},
},
],
});
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);

// Create the browser window.
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders['User-Agent'] = 'Chrome';
Expand Down
18 changes: 18 additions & 0 deletions notarize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const {notarize} = require('electron-notarize');
const {projectName, appleId} = require('./config.json');

exports.default = async function notarizing(context) {
const {electronPlatformName, appOutDir} = context;
if (electronPlatformName !== 'darwin') {
return;
}

const appName = context.packager.appInfo.productFilename;

return await notarize({
appBundleId: `com.${projectName.toLowerCase()}`,
appPath: `${appOutDir}/${appName}.app`,
appleId,
appleIdPassword: '@keychain:AC_PASSWORD',
});
};
55 changes: 55 additions & 0 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"windows:build": "cross-env TARGET=windows npm run electron:build",
"mac": "cross-env TARGET=mac npm run electron:start",
"mac:build": "cross-env TARGET=mac npm run electron:build",
"mac:build2": "electron-builder build --config ./electron-builder.js",
"linux": "cross-env TARGET=linux npm run electron:start",
"linux:build": "cross-env TARGET=linux npm run electron:build",
"test": "jest",
Expand Down Expand Up @@ -51,12 +52,12 @@
"agora-electron-sdk": "^3.0.0-build.661"
},
"devDependencies": {
"@bam.tech/react-native-make": "3.0.0",
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.9.0",
"@babel/runtime": "^7.6.2",
"@bam.tech/react-native-make": "3.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.3.2",
"@react-native-community/eslint-config": "^1.0.0",
"@types/agora-rtc-sdk": "^3.1.0",
Expand All @@ -74,6 +75,7 @@
"del": "^5.1.0",
"electron": "5.0.8",
"electron-builder": "^22.4.1",
"electron-notarize": "^1.0.0",
"eslint": "^6.5.1",
"gulp": "^4.0.2",
"html-webpack-plugin": "^4.3.0",
Expand Down

0 comments on commit 5213904

Please sign in to comment.