@@ -57691,9 +57691,9 @@ async function updateBetaBuildLocalization(betaBuildLocalization, whatsNew) {
5769157691async function pollForValidBuild(project, maxRetries = 60, interval = 30) {
5769257692 var _a, _b, _c;
5769357693 (0, utilities_1.log)(`Polling build validation...`);
57694- await new Promise(resolve => setTimeout(resolve, interval * 1000));
5769557694 let retries = 0;
5769657695 while (++retries < maxRetries) {
57696+ await new Promise(resolve => setTimeout(resolve, interval * 1000));
5769757697 core.info(`Polling for build... Attempt ${retries}/${maxRetries}`);
5769857698 let { preReleaseVersion, build } = await getLastPreReleaseVersionAndBuild(project);
5769957699 if (preReleaseVersion) {
@@ -57728,7 +57728,6 @@ async function pollForValidBuild(project, maxRetries = 60, interval = 30) {
5772857728 else {
5772957729 core.info(`Waiting for pre-release build ${project.versionString}...`);
5773057730 }
57731- await new Promise(resolve => setTimeout(resolve, interval * 1000));
5773257731 }
5773357732 throw new Error('Timed out waiting for valid build!');
5773457733}
@@ -58403,21 +58402,27 @@ async function ExportXcodeArchive(projectRef) {
5840358402 if (projectRef.platform === 'macOS') {
5840458403 if (!projectRef.isAppStoreUpload()) {
5840558404 const notarizeInput = core.getInput('notarize') || 'true';
58405+ projectRef.executablePath = await getFirstPathWithGlob(`${projectRef.exportPath}/**/*.app`);
5840658406 const notarize = notarizeInput === 'true';
5840758407 core.debug(`Notarize? ${notarize}`);
5840858408 if (notarize) {
58409- projectRef.executablePath = await createMacOSInstallerPkg(projectRef);
58410- }
58411- else {
58412- projectRef.executablePath = await getFileAtGlobPath(`${projectRef.exportPath}/**/*.app`);
58409+ await signMacOSAppBundle(projectRef);
58410+ if (projectRef.exportOption !== 'steam') {
58411+ projectRef.executablePath = await createMacOSInstallerPkg(projectRef);
58412+ }
58413+ else {
58414+ const zipPath = path.join(projectRef.exportPath, projectRef.executablePath.replace('.app', '.zip'));
58415+ await (0, exec_1.exec)('ditto', ['-c', '-k', '--sequesterRsrc', '--keepParent', projectRef.executablePath, zipPath]);
58416+ await notarizeArchive(projectRef, zipPath, projectRef.executablePath);
58417+ }
5841358418 }
5841458419 }
5841558420 else {
58416- projectRef.executablePath = await getFileAtGlobPath (`${projectRef.exportPath}/**/*.pkg`);
58421+ projectRef.executablePath = await getFirstPathWithGlob (`${projectRef.exportPath}/**/*.pkg`);
5841758422 }
5841858423 }
5841958424 else {
58420- projectRef.executablePath = await getFileAtGlobPath (`${projectRef.exportPath}/**/*.ipa`);
58425+ projectRef.executablePath = await getFirstPathWithGlob (`${projectRef.exportPath}/**/*.ipa`);
5842158426 }
5842258427 try {
5842358428 await fs.promises.access(projectRef.executablePath, fs.constants.R_OK);
@@ -58429,34 +58434,134 @@ async function ExportXcodeArchive(projectRef) {
5842958434 core.setOutput('executable', projectRef.executablePath);
5843058435 return projectRef;
5843158436}
58432- async function getFileAtGlobPath (globPattern) {
58437+ async function getFirstPathWithGlob (globPattern) {
5843358438 const globber = await glob.create(globPattern);
5843458439 const files = await globber.glob();
5843558440 if (files.length === 0) {
5843658441 throw new Error(`No file found at: ${globPattern}`);
5843758442 }
5843858443 return files[0];
5843958444}
58445+ async function signMacOSAppBundle(projectRef) {
58446+ const appPath = await getFirstPathWithGlob(`${projectRef.exportPath}/**/*.app`);
58447+ await fs.promises.access(appPath, fs.constants.R_OK);
58448+ const stat = await fs.promises.stat(appPath);
58449+ if (!stat.isDirectory()) {
58450+ throw new Error(`Not a valid app bundle: ${appPath}`);
58451+ }
58452+ const signAppBundlePath = __nccwpck_require__.ab + "sign-app-bundle.sh";
58453+ core.info(`Signing app bundle: ${appPath}`);
58454+ let codesignOutput = '';
58455+ const codesignExitCode = await (0, exec_1.exec)(__nccwpck_require__.ab + "sign-app-bundle.sh", [appPath, projectRef.entitlementsPath], {
58456+ listeners: {
58457+ stdout: (data) => {
58458+ codesignOutput += data.toString();
58459+ }
58460+ },
58461+ ignoreReturnCode: true
58462+ });
58463+ if (codesignExitCode !== 0) {
58464+ (0, utilities_1.log)(codesignOutput, 'error');
58465+ throw new Error(`Failed to code sign the app!`);
58466+ }
58467+ core.info(codesignOutput);
58468+ }
5844058469async function createMacOSInstallerPkg(projectRef) {
5844158470 core.info('Creating macOS installer pkg...');
5844258471 let output = '';
5844358472 const pkgPath = `${projectRef.exportPath}/${projectRef.projectName}.pkg`;
58444- const appPath = await getFileAtGlobPath (`${projectRef.exportPath}/**/*.app`);
58445- await (0, exec_1.exec)('productbuild ', ['--component', appPath, '/Applications', pkgPath], {
58473+ const appPath = await getFirstPathWithGlob (`${projectRef.exportPath}/**/*.app`);
58474+ const productBuildExitCode = await (0, exec_1.exec)('xcrun ', ['productbuild', '--component', appPath, '/Applications', pkgPath], {
5844658475 listeners: {
5844758476 stdout: (data) => {
5844858477 output += data.toString();
5844958478 }
58450- }
58479+ },
58480+ ignoreReturnCode: true
5845158481 });
58482+ if (productBuildExitCode !== 0) {
58483+ (0, utilities_1.log)(output, 'error');
58484+ throw new Error(`Failed to create the pkg!`);
58485+ }
5845258486 try {
5845358487 await fs.promises.access(pkgPath, fs.constants.R_OK);
5845458488 }
5845558489 catch (error) {
5845658490 throw new Error(`Failed to create the pkg at: ${pkgPath}!`);
5845758491 }
58492+ const signPkgPath = __nccwpck_require__.ab + "sign-app-pkg.sh";
58493+ core.info(`Signing pkg: ${pkgPath}`);
58494+ let codesignOutput = '';
58495+ const codesignExitCode = await (0, exec_1.exec)(__nccwpck_require__.ab + "sign-app-pkg.sh", [pkgPath], {
58496+ listeners: {
58497+ stdout: (data) => {
58498+ codesignOutput += data.toString();
58499+ }
58500+ },
58501+ ignoreReturnCode: true
58502+ });
58503+ if (codesignExitCode !== 0) {
58504+ (0, utilities_1.log)(codesignOutput, 'error');
58505+ throw new Error(`Failed to code sign the pkg!`);
58506+ }
5845858507 return pkgPath;
5845958508}
58509+ async function notarizeArchive(projectRef, archivePath, staplePath) {
58510+ const notarizeArgs = [
58511+ 'notarytool',
58512+ 'submit',
58513+ '--key', projectRef.credential.appStoreConnectKeyPath,
58514+ '--key-id', projectRef.credential.appStoreConnectKeyId,
58515+ '--issuer', projectRef.credential.appStoreConnectIssuerId,
58516+ '--team-id', projectRef.credential.teamId,
58517+ '--wait',
58518+ '--no-progress',
58519+ '--output-format', 'json',
58520+ ];
58521+ if (core.isDebug()) {
58522+ notarizeArgs.push('--verbose');
58523+ }
58524+ let notarizeOutput = '';
58525+ const notarizeExitCode = await (0, exec_1.exec)(xcrun, [...notarizeArgs, archivePath], {
58526+ listeners: {
58527+ stdout: (data) => {
58528+ notarizeOutput += data.toString();
58529+ }
58530+ },
58531+ ignoreReturnCode: true
58532+ });
58533+ if (notarizeExitCode !== 0) {
58534+ (0, utilities_1.log)(notarizeOutput, 'error');
58535+ throw new Error(`Failed to notarize the app!`);
58536+ }
58537+ core.debug(notarizeOutput);
58538+ const notaryResult = JSON.parse(notarizeOutput);
58539+ if (notaryResult.status !== 'Accepted') {
58540+ throw new Error(`Notarization failed! Status: ${notaryResult.status} | ${notaryResult.message}`);
58541+ }
58542+ const stapleArgs = [
58543+ 'stapler',
58544+ 'staple',
58545+ staplePath,
58546+ ];
58547+ if (core.isDebug()) {
58548+ stapleArgs.push('--verbose');
58549+ }
58550+ let stapleOutput = '';
58551+ const stapleExitCode = await (0, exec_1.exec)(xcrun, stapleArgs, {
58552+ listeners: {
58553+ stdout: (data) => {
58554+ stapleOutput += data.toString();
58555+ }
58556+ },
58557+ ignoreReturnCode: true
58558+ });
58559+ if (stapleExitCode !== 0) {
58560+ (0, utilities_1.log)(stapleOutput, 'error');
58561+ throw new Error(`Failed to staple the notarization ticket!`);
58562+ }
58563+ core.info(stapleOutput);
58564+ }
5846058565async function getExportOptions(projectRef) {
5846158566 const exportOptionPlistInput = core.getInput('export-option-plist');
5846258567 let exportOptionsPath = undefined;
0 commit comments