Skip to content

Commit

Permalink
Add supports for notarize file
Browse files Browse the repository at this point in the history
  • Loading branch information
panther7 committed Aug 12, 2023
1 parent d0eabf3 commit 7be1729
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ For notarization, you need the following things:

* `options` Object
* `tool` String - The notarization tool to use, default is `notarytool`. Can be `legacy` or `notarytool`. `notarytool` is substantially (10x) faster and `legacy` is deprecated and will **stop working** on November 1st 2023.
* `appPath` String - The absolute path to your `.app` file
* `appPath` String - The absolute path to your `.app`, `.zip`, `.dmg` or `.pkg` file
* There are different options for each tool: Notarytool
* There are three authentication methods available: user name with password:
* `appleId` String - The username of your apple developer account
Expand Down
37 changes: 23 additions & 14 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import debug from 'debug';
import * as path from 'path';
import fs from 'fs';

import { spawn } from './spawn';
import { makeSecret, withTempDir } from './helpers';
Expand Down Expand Up @@ -49,26 +50,34 @@ export async function isNotaryToolAvailable() {
export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions) {
d('starting notarize process for app:', opts.appPath);
return await withTempDir(async dir => {
const zipPath = path.resolve(dir, `${path.parse(opts.appPath).name}.zip`);
d('zipping application to:', zipPath);
const zipResult = await spawn(
'ditto',
['-c', '-k', '--sequesterRsrc', '--keepParent', path.basename(opts.appPath), zipPath],
{
cwd: path.dirname(opts.appPath),
},
);
if (zipResult.code !== 0) {
throw new Error(
`Failed to zip application, exited with code: ${zipResult.code}\n\n${zipResult.output}`,
const parsedAppPath = path.parse(opts.appPath);
const fsStat = fs.statSync(opts.appPath);
let filename: string;
if (fsStat.isFile()) {
filename = opts.appPath;
d(`appPath is file, attempting to upload to Apple`);
} else {
filename = path.resolve(dir, `${parsedAppPath.name}.zip`);
d('zipping application to:', filename);
const zipResult = await spawn(
'ditto',
['-c', '-k', '--sequesterRsrc', '--keepParent', parsedAppPath.base, filename],
{
cwd: parsedAppPath.dir,
},
);
if (zipResult.code !== 0) {
throw new Error(
`Failed to zip application, exited with code: ${zipResult.code}\n\n${zipResult.output}`,
);
}
d('zip succeeded, attempting to upload to Apple');
}
d('zip succeeded, attempting to upload to Apple');

const notarizeArgs = [
'notarytool',
'submit',
zipPath,
filename,
...authorizationArgs(opts),
'--wait',
'--output-format',
Expand Down

0 comments on commit 7be1729

Please sign in to comment.