Skip to content

Commit

Permalink
feat: add support for .pkg and .dmg files (#169)
Browse files Browse the repository at this point in the history
* feat: add support for .pkg and .dmg files

* fix: fix zipPath
  • Loading branch information
DanielMcAssey committed Feb 15, 2024
1 parent 75d914e commit 571ebac
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,33 @@ 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 fileExt = path.extname(opts.appPath);
let filePath;
if (fileExt === '.dmg' || fileExt === '.pkg') {
filePath = path.resolve(dir, opts.appPath);
d('attempting to upload file to Apple: ', filePath);
} else {
filePath = path.resolve(dir, `${path.parse(opts.appPath).name}.zip`);
d('zipping application to:', filePath);
const zipResult = await spawn(
'ditto',
['-c', '-k', '--sequesterRsrc', '--keepParent', path.basename(opts.appPath), filePath],
{
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}`,
);
}
d('zip succeeded, attempting to upload to Apple');
}
d('zip succeeded, attempting to upload to Apple');

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

0 comments on commit 571ebac

Please sign in to comment.