@@ -58820,7 +58820,6 @@ async function getPlatformSdkVersion(buildSettingsOutput) {
5882058820}
5882158821async function getSdkInfo(platform, version) {
5882258822 const output = await execXcodeBuild(['-showsdks', '-json']);
58823- core.debug(`Installed SDKs:\n${output}`);
5882458823 const installedSdks = JSON.parse(output);
5882558824 const platformMap = {
5882658825 'iOS': 'iphoneos',
@@ -59319,20 +59318,20 @@ async function notarizeArchive(projectRef, archivePath, staplePath) {
5931959318 '--no-progress',
5932059319 '--output-format', 'json',
5932159320 ];
59322- if (core.isDebug()) {
59323- notarizeArgs.push('--verbose' );
59321+ if (! core.isDebug()) {
59322+ core.info(`[command]${xcrun} ${ notarizeArgs.join(' ')} ${archivePath}` );
5932459323 }
5932559324 else {
59326- core.info(`[command]${xcrun} ${ notarizeArgs.join(' ')} ${archivePath}` );
59325+ notarizeArgs.push('--verbose' );
5932759326 }
5932859327 let notarizeOutput = '';
5932959328 const notarizeExitCode = await (0, exec_1.exec)(xcrun, [...notarizeArgs, archivePath], {
59330- silent: !core.isDebug(),
5933159329 listeners: {
5933259330 stdout: (data) => {
5933359331 notarizeOutput += data.toString();
5933459332 }
5933559333 },
59334+ silent: !core.isDebug(),
5933659335 ignoreReturnCode: true
5933759336 });
5933859337 if (notarizeExitCode !== 0) {
@@ -59350,20 +59349,20 @@ async function notarizeArchive(projectRef, archivePath, staplePath) {
5935059349 'staple',
5935159350 staplePath,
5935259351 ];
59353- if (core.isDebug()) {
59354- stapleArgs.push('--verbose' );
59352+ if (! core.isDebug()) {
59353+ core.info(`[command]${xcrun} ${ stapleArgs.join(' ')}` );
5935559354 }
5935659355 else {
59357- core.info(`[command]${xcrun} ${ stapleArgs.join(' ')}` );
59356+ stapleArgs.push('--verbose' );
5935859357 }
5935959358 let stapleOutput = '';
5936059359 const stapleExitCode = await (0, exec_1.exec)(xcrun, stapleArgs, {
59361- silent: !core.isDebug(),
5936259360 listeners: {
5936359361 stdout: (data) => {
5936459362 stapleOutput += data.toString();
5936559363 }
5936659364 },
59365+ silent: !core.isDebug(),
5936759366 ignoreReturnCode: true
5936859367 });
5936959368 if (stapleExitCode !== 0) {
@@ -59380,7 +59379,6 @@ async function notarizeArchive(projectRef, archivePath, staplePath) {
5938059379 }
5938159380}
5938259381async function getNotarizationLog(projectRef, id) {
59383- let output = '';
5938459382 const notaryLogArgs = [
5938559383 'notarytool',
5938659384 'log', id,
@@ -59393,98 +59391,12 @@ async function getNotarizationLog(projectRef, id) {
5939359391 notaryLogArgs.push('--verbose');
5939459392 }
5939559393 const logExitCode = await (0, exec_1.exec)(xcrun, notaryLogArgs, {
59396- listeners: {
59397- stdout: (data) => {
59398- output += data.toString();
59399- }
59400- },
5940159394 ignoreReturnCode: true
5940259395 });
5940359396 if (logExitCode !== 0) {
5940459397 throw new Error(`Failed to get notarization log!`);
5940559398 }
5940659399}
59407- async function execXcodeBuild(xcodeBuildArgs) {
59408- let exitCode = 1;
59409- let output = '';
59410- if (!core.isDebug()) {
59411- core.startGroup(`[command]${xcodebuild} ${xcodeBuildArgs.join(' ')}`);
59412- }
59413- try {
59414- exitCode = await (0, exec_1.exec)(xcodebuild, xcodeBuildArgs, {
59415- listeners: {
59416- stdline(data) {
59417- output += data + '\n';
59418- if (!core.isDebug()) {
59419- core.info(data);
59420- }
59421- },
59422- errline(data) {
59423- output += data + '\n';
59424- if (!core.isDebug()) {
59425- core.error(data);
59426- }
59427- }
59428- },
59429- silent: !core.isDebug(),
59430- ignoreReturnCode: true
59431- });
59432- await parseBundleLog(output);
59433- }
59434- finally {
59435- core.endGroup();
59436- }
59437- if (exitCode !== 0) {
59438- throw new Error(`xcodebuild exited with code: ${exitCode}`);
59439- }
59440- return output;
59441- }
59442- async function execWithXcBeautify(xcodeBuildArgs) {
59443- try {
59444- await (0, exec_1.exec)('xcbeautify', ['--version'], { silent: true });
59445- }
59446- catch (error) {
59447- core.debug('Installing xcbeautify...');
59448- await (0, exec_1.exec)('brew', ['install', 'xcbeautify']);
59449- }
59450- const beautifyArgs = ['--quiet', '--is-ci', '--disable-logging'];
59451- const xcBeautifyProcess = (0, child_process_1.spawn)('xcbeautify', beautifyArgs, {
59452- stdio: ['pipe', process.stdout, process.stderr]
59453- });
59454- core.info(`[command]${xcodebuild} ${xcodeBuildArgs.join(' ')}`);
59455- let errorOutput = '';
59456- const exitCode = await (0, exec_1.exec)(xcodebuild, xcodeBuildArgs, {
59457- listeners: {
59458- stdout: (data) => {
59459- xcBeautifyProcess.stdin.write(data);
59460- },
59461- stderr: (data) => {
59462- xcBeautifyProcess.stdin.write(data);
59463- errorOutput += data.toString();
59464- }
59465- },
59466- silent: true,
59467- ignoreReturnCode: true
59468- });
59469- xcBeautifyProcess.stdin.end();
59470- await new Promise((resolve, reject) => {
59471- xcBeautifyProcess.stdin.on('finish', () => {
59472- xcBeautifyProcess.on('close', (code) => {
59473- if (code !== 0) {
59474- reject(new Error(`xcbeautify exited with code ${code}`));
59475- }
59476- else {
59477- resolve();
59478- }
59479- });
59480- });
59481- });
59482- if (exitCode !== 0) {
59483- (0, utilities_1.log)(`xcodebuild error: ${errorOutput}`, 'error');
59484- await parseBundleLog(errorOutput);
59485- throw new Error(`xcodebuild exited with code: ${exitCode}`);
59486- }
59487- }
5948859400async function parseBundleLog(errorOutput) {
5948959401 const logFilePathMatch = errorOutput.match(/_createLoggingBundleAtPath:.*Created bundle at path "([^"]+)"/);
5949059402 if (!logFilePathMatch) {
@@ -59500,11 +59412,10 @@ async function parseBundleLog(errorOutput) {
5950059412 (0, utilities_1.log)(`Log file is a directory. Files: ${files.join(', ')}`, 'info');
5950159413 return;
5950259414 }
59503- const logFileContent = await fs.promises.readFile(logFilePath, 'utf8');
59504- (0, utilities_1.log)(`----- Log content: -----\n${logFileContent}\n-----------------------------------`, 'info');
59415+ await (0, utilities_1.getFileContents)(logFilePath);
5950559416 }
5950659417 catch (error) {
59507- (0, utilities_1.log)(`Error reading log file: ${error.message }`, 'error');
59418+ (0, utilities_1.log)(`Error reading log file:\n ${error}`, 'error');
5950859419 }
5950959420}
5951059421async function ValidateApp(projectRef) {
@@ -59569,27 +59480,17 @@ async function UploadApp(projectRef) {
5956959480 '--apiIssuer', projectRef.credential.appStoreConnectIssuerId,
5957059481 '--output-format', 'json'
5957159482 ];
59572- if (!core.isDebug()) {
59573- core.info(`[command]${xcrun} ${uploadArgs.join(' ')}`);
59574- }
59575- else {
59576- uploadArgs.push('--verbose');
59577- }
5957859483 let output = '';
59579- const exitCode = await (0, exec_1.exec)(xcrun, uploadArgs, {
59580- listeners: {
59581- stdout: (data) => {
59582- output += data.toString();
59583- }
59584- },
59585- silent: !core.isDebug(),
59586- ignoreReturnCode: true
59587- });
59588- const outputJson = JSON.stringify(JSON.parse(output), null, 2);
59589- if (exitCode !== 0) {
59484+ let outputJson = '';
59485+ try {
59486+ output = await execXcRun(uploadArgs);
59487+ }
59488+ catch (error) {
59489+ outputJson = JSON.stringify(JSON.parse(output), null, 2);
5959059490 (0, utilities_1.log)(outputJson, 'error');
59591- throw new Error(`Failed to upload app! `);
59491+ throw new Error(`Failed to upload app: ${error} `);
5959259492 }
59493+ outputJson = JSON.stringify(JSON.parse(output), null, 2);
5959359494 core.debug(outputJson);
5959459495 try {
5959559496 const whatsNew = await getWhatsNew();
@@ -59637,22 +59538,135 @@ async function getWhatsNew() {
5963759538 }
5963859539 return whatsNew;
5963959540}
59640- async function execGit(args) {
59541+ async function execXcodeBuild(xcodeBuildArgs) {
59542+ let exitCode = 1;
5964159543 let output = '';
59642- if (!core.isDebug()) {
59643- core.info(`[command]git ${args.join(' ')}`);
59544+ exitCode = await (0, exec_1.exec)(xcodebuild, xcodeBuildArgs, {
59545+ listeners: {
59546+ stdout(data) {
59547+ output += data.toString();
59548+ },
59549+ stderr(data) {
59550+ output += data.toString();
59551+ }
59552+ },
59553+ ignoreReturnCode: true
59554+ });
59555+ if (exitCode !== 0) {
59556+ await parseBundleLog(output);
59557+ throw new Error(`xcodebuild exited with code: ${exitCode}`);
59558+ }
59559+ return output;
59560+ }
59561+ async function execWithXcBeautify(xcodeBuildArgs) {
59562+ try {
59563+ await (0, exec_1.exec)('xcbeautify', ['--version'], { silent: true });
59564+ }
59565+ catch (error) {
59566+ core.debug('Installing xcbeautify...');
59567+ await (0, exec_1.exec)('brew', ['install', 'xcbeautify']);
5964459568 }
59645- const exitCode = await (0, exec_1.exec)('git', args, {
59569+ const beautifyArgs = ['--quiet', '--is-ci', '--disable-logging'];
59570+ const xcBeautifyProcess = (0, child_process_1.spawn)('xcbeautify', beautifyArgs, {
59571+ stdio: ['pipe', process.stdout, process.stderr]
59572+ });
59573+ core.info(`[command]${xcodebuild} ${xcodeBuildArgs.join(' ')}`);
59574+ let errorOutput = '';
59575+ const exitCode = await (0, exec_1.exec)(xcodebuild, xcodeBuildArgs, {
5964659576 listeners: {
5964759577 stdout: (data) => {
59648- output += data.toString();
59578+ xcBeautifyProcess.stdin.write(data);
59579+ },
59580+ stderr: (data) => {
59581+ xcBeautifyProcess.stdin.write(data);
59582+ errorOutput += data.toString();
5964959583 }
5965059584 },
59651- silent: !core.isDebug()
59585+ silent: true,
59586+ ignoreReturnCode: true
5965259587 });
59653- if (exitCode > 0) {
59654- (0, utilities_1.log)(output, 'error');
59655- throw new Error(`Git failed with exit code: ${exitCode}`);
59588+ xcBeautifyProcess.stdin.end();
59589+ await new Promise((resolve, reject) => {
59590+ xcBeautifyProcess.stdin.on('finish', () => {
59591+ xcBeautifyProcess.on('close', (code) => {
59592+ if (code !== 0) {
59593+ reject(new Error(`xcbeautify exited with code ${code}`));
59594+ }
59595+ else {
59596+ resolve();
59597+ }
59598+ });
59599+ });
59600+ });
59601+ if (exitCode !== 0) {
59602+ (0, utilities_1.log)(`xcodebuild error: ${errorOutput}`, 'error');
59603+ await parseBundleLog(errorOutput);
59604+ throw new Error(`xcodebuild exited with code: ${exitCode}`);
59605+ }
59606+ }
59607+ async function execXcRun(args) {
59608+ let exitCode = 1;
59609+ let output = '';
59610+ if (!core.isDebug()) {
59611+ core.startGroup(`[command]${xcrun} ${args.join(' ')}`);
59612+ }
59613+ else {
59614+ args.push('--verbose');
59615+ }
59616+ try {
59617+ exitCode = await (0, exec_1.exec)(xcrun, args, {
59618+ listeners: {
59619+ stdline(data) {
59620+ output += `${data}\n`;
59621+ if (!core.isDebug()) {
59622+ core.info(data);
59623+ }
59624+ }
59625+ },
59626+ ignoreReturnCode: true,
59627+ silent: !core.isDebug()
59628+ });
59629+ if (exitCode !== 0) {
59630+ throw new Error(`xcrun exited with code: ${exitCode}`);
59631+ }
59632+ }
59633+ finally {
59634+ if (!core.isDebug()) {
59635+ core.endGroup();
59636+ }
59637+ }
59638+ return output;
59639+ }
59640+ async function execGit(args) {
59641+ let exitCode = 1;
59642+ let output = '';
59643+ try {
59644+ if (!core.isDebug()) {
59645+ core.startGroup(`[command]git ${args.join(' ')}`);
59646+ }
59647+ exitCode = await (0, exec_1.exec)('git', args, {
59648+ listeners: {
59649+ stdout: (data) => {
59650+ output += data.toString();
59651+ },
59652+ stdline(data) {
59653+ if (!core.isDebug()) {
59654+ core.info(data);
59655+ }
59656+ }
59657+ },
59658+ silent: !core.isDebug(),
59659+ ignoreReturnCode: true
59660+ });
59661+ if (exitCode > 0) {
59662+ (0, utilities_1.log)(output, 'error');
59663+ throw new Error(`Git failed with exit code: ${exitCode}`);
59664+ }
59665+ }
59666+ finally {
59667+ if (!core.isDebug()) {
59668+ core.endGroup();
59669+ }
5965659670 }
5965759671 return output;
5965859672}
0 commit comments