Skip to content

Commit

Permalink
updating example
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpatrick committed Oct 14, 2021
1 parent c39c8ef commit 115c98c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 77 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ node_modules
dist/
yarn.lock
package-lock.json
/.idea
*.iml
docker.env
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@ If you can't use GitHub, you can use other providers:
},
...

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:

npm run publish-linux-docker
NOTE: The Mac OS signing/notarization process must be run on Mac OS.

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."
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."

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

9. Update the version in `package.json`, commit and push to GitHub.
8. Update the version in `package.json`, commit and push to GitHub.

10. Do steps 5 and 6 again.
9. Do steps 5 and 6 again.

11. Open the installed version of the app and see that it updates itself.
10. Open the installed version of the app and see that it updates itself.
22 changes: 0 additions & 22 deletions build/linuxInstallers.sh

This file was deleted.

37 changes: 0 additions & 37 deletions build/linuxInstallersInDocker.sh

This file was deleted.

72 changes: 66 additions & 6 deletions build/notarize.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,77 @@
const { notarize } = require('electron-notarize');
const path = require('path');
const fs = require('fs');
const jsYaml = require('js-yaml');

function findPackageJsonPath() {
let dirName = process.cwd();

while(dirName) {
const packageJsonFilePath = path.join(dirName, 'package.json');
if (fs.existsSync(packageJsonFilePath)) {
return packageJsonFilePath;
} else if (dirName === '/') {
break;
}
dirName = path.dirname(dirName);
}
return undefined;
}

function getAppId(context) {
// Try to get the appId from the packager
const config = context.packager.info._configuration;
if (config && config.appId) {
console.log('Found appId in packager');
return config.appId;
}

// Try to get the appId from the builder-effective-config.yml file
const builderEffectiveConfigPath = path.join(context.outDir, 'builder-effective-config.yaml');
if (fs.existsSync(builderEffectiveConfigPath)) {
const builderEffectiveConfigText = fs.readFileSync(builderEffectiveConfigPath);
const builderEffectiveConfig = jsYaml.load(builderEffectiveConfigText);
if (builderEffectiveConfig['appId']) {
console.log('Found appId in %s', builderEffectiveConfigPath);
return builderEffectiveConfig['appId'];
}
}

// Try to get the appId from the package.json file
const packageJsonFilePath = findPackageJsonPath();
if (packageJsonFilePath) {
try {
const packageJson = require(packageJsonFilePath);
if (packageJson['build'] && packageJson['build']['appId']) {
console.log('Found appId in %s', packageJsonFilePath);
return packageJson['build']['appId'];
}
} catch (err) {
// swallow the error
console.log('Failed to read %s: %s', packageJsonFilePath, err);
}
}

// finally, check the APP_ID environment variable
if (process.env.APP_ID) {
console.log('Found appId in APP_ID environment variable');
return process.env.APP_ID;
}
throw new Error('Unable to find the application ID');
}

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

const appId = getAppId(context);
const appName = context.packager.appInfo.productFilename;
const appPath = path.normalize(path.join(process.cwd(), 'dist', 'mac', `${appName}.app`));
console.log('calling notarize with appPath = %s', appPath);
return await notarize({
appBundleId: 'com.github.iffy.electronupdaterexample',
const appPath = path.normalize(path.join(context.outDir, 'mac', `${appName}.app`));
console.log('calling notarize for appId = %s with appPath = %s', appId, appPath);
return notarize({
appBundleId: appId,
appPath: appPath,
appleId: process.env.APPLEID,
appleIdPassword: process.env.APPLEIDPASS,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"devDependencies": {
"electron": "^14.0.1",
"electron-builder": "^22.11.7"
"electron-builder": "^22.11.7",
"js-yaml": "^4.1.0"
},
"dependencies": {
"electron-log": "^4.4.1",
Expand Down

0 comments on commit 115c98c

Please sign in to comment.