Skip to content

Commit 115c98c

Browse files
committed
updating example
1 parent c39c8ef commit 115c98c

File tree

6 files changed

+74
-77
lines changed

6 files changed

+74
-77
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ node_modules
22
dist/
33
yarn.lock
44
package-lock.json
5-
/.idea
6-
*.iml
7-
docker.env

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ If you can't use GitHub, you can use other providers:
6969
},
7070
...
7171

72-
NOTE: The Mac OS signing/notarization process must be run on Mac OS. This application is set up to build Linux installers using the `electronuserland/builder` Docker image. Run:
73-
74-
npm run publish-linux-docker
72+
NOTE: The Mac OS signing/notarization process must be run on Mac OS.
7573

76-
7. Release the release on GitHub by going to <https://github.com/YOUR_GIT_HUB_USERNAME/electron-updater-example/releases>, editing the release and clicking "Publish release."
74+
6. Release the release on GitHub by going to <https://github.com/YOUR_GIT_HUB_USERNAME/electron-updater-example/releases>, editing the release and clicking "Publish release."
7775

78-
8. Download and install the app from <https://github.com/YOUR_GIT_HUB_USERNAME/electron-updater-example/releases>.
76+
7. Download and install the app from <https://github.com/YOUR_GIT_HUB_USERNAME/electron-updater-example/releases>.
7977

80-
9. Update the version in `package.json`, commit and push to GitHub.
78+
8. Update the version in `package.json`, commit and push to GitHub.
8179

82-
10. Do steps 5 and 6 again.
80+
9. Do steps 5 and 6 again.
8381

84-
11. Open the installed version of the app and see that it updates itself.
82+
10. Open the installed version of the app and see that it updates itself.

build/linuxInstallers.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

build/linuxInstallersInDocker.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

build/notarize.js

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,77 @@
11
const { notarize } = require('electron-notarize');
22
const path = require('path');
3+
const fs = require('fs');
4+
const jsYaml = require('js-yaml');
5+
6+
function findPackageJsonPath() {
7+
let dirName = process.cwd();
8+
9+
while(dirName) {
10+
const packageJsonFilePath = path.join(dirName, 'package.json');
11+
if (fs.existsSync(packageJsonFilePath)) {
12+
return packageJsonFilePath;
13+
} else if (dirName === '/') {
14+
break;
15+
}
16+
dirName = path.dirname(dirName);
17+
}
18+
return undefined;
19+
}
20+
21+
function getAppId(context) {
22+
// Try to get the appId from the packager
23+
const config = context.packager.info._configuration;
24+
if (config && config.appId) {
25+
console.log('Found appId in packager');
26+
return config.appId;
27+
}
28+
29+
// Try to get the appId from the builder-effective-config.yml file
30+
const builderEffectiveConfigPath = path.join(context.outDir, 'builder-effective-config.yaml');
31+
if (fs.existsSync(builderEffectiveConfigPath)) {
32+
const builderEffectiveConfigText = fs.readFileSync(builderEffectiveConfigPath);
33+
const builderEffectiveConfig = jsYaml.load(builderEffectiveConfigText);
34+
if (builderEffectiveConfig['appId']) {
35+
console.log('Found appId in %s', builderEffectiveConfigPath);
36+
return builderEffectiveConfig['appId'];
37+
}
38+
}
39+
40+
// Try to get the appId from the package.json file
41+
const packageJsonFilePath = findPackageJsonPath();
42+
if (packageJsonFilePath) {
43+
try {
44+
const packageJson = require(packageJsonFilePath);
45+
if (packageJson['build'] && packageJson['build']['appId']) {
46+
console.log('Found appId in %s', packageJsonFilePath);
47+
return packageJson['build']['appId'];
48+
}
49+
} catch (err) {
50+
// swallow the error
51+
console.log('Failed to read %s: %s', packageJsonFilePath, err);
52+
}
53+
}
54+
55+
// finally, check the APP_ID environment variable
56+
if (process.env.APP_ID) {
57+
console.log('Found appId in APP_ID environment variable');
58+
return process.env.APP_ID;
59+
}
60+
throw new Error('Unable to find the application ID');
61+
}
362

463
exports.default = async function notarizing(context) {
5-
const { electronPlatformName, appOutDir } = context;
6-
if (electronPlatformName !== 'darwin') {
64+
const { electronPlatformName } = context;
65+
if (electronPlatformName !== 'darwin' || process.env.CSC_IDENTITY_AUTO_DISCOVERY === 'false') {
766
return;
867
}
968

69+
const appId = getAppId(context);
1070
const appName = context.packager.appInfo.productFilename;
11-
const appPath = path.normalize(path.join(process.cwd(), 'dist', 'mac', `${appName}.app`));
12-
console.log('calling notarize with appPath = %s', appPath);
13-
return await notarize({
14-
appBundleId: 'com.github.iffy.electronupdaterexample',
71+
const appPath = path.normalize(path.join(context.outDir, 'mac', `${appName}.app`));
72+
console.log('calling notarize for appId = %s with appPath = %s', appId, appPath);
73+
return notarize({
74+
appBundleId: appId,
1575
appPath: appPath,
1676
appleId: process.env.APPLEID,
1777
appleIdPassword: process.env.APPLEIDPASS,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111
"devDependencies": {
1212
"electron": "^14.0.1",
13-
"electron-builder": "^22.11.7"
13+
"electron-builder": "^22.11.7",
14+
"js-yaml": "^4.1.0"
1415
},
1516
"dependencies": {
1617
"electron-log": "^4.4.1",

0 commit comments

Comments
 (0)