Skip to content

Commit 98400e4

Browse files
show destinations
1 parent 240e7ca commit 98400e4

3 files changed

Lines changed: 88 additions & 14 deletions

File tree

dist/index.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58461,7 +58461,14 @@ async function GetProjectDetails(credential, xcodeVersion) {
5846158461
if (platform !== 'macOS') {
5846258462
await checkSimulatorsAvailable(platform);
5846358463
}
58464-
const destination = core.getInput('destination');
58464+
const destinationInput = core.getInput('destination');
58465+
let destination;
58466+
if (destinationInput) {
58467+
destination = destinationInput;
58468+
}
58469+
else {
58470+
destination = `generic/platform=${platform}`;
58471+
}
5846558472
core.debug(`Using destination: ${destination}`);
5846658473
const bundleId = await getBuildSettings(projectPath, scheme, platform, destination);
5846758474
core.info(`Bundle ID: ${bundleId}`);
@@ -58660,16 +58667,36 @@ async function getSupportedPlatform(projectPath) {
5866058667
};
5866158668
return platformMap[platformName];
5866258669
}
58670+
async function getDestination(projectPath, scheme, platform) {
58671+
let destinationOutput = '';
58672+
const destinationArgs = [
58673+
'-project', projectPath,
58674+
'-scheme', scheme,
58675+
'-showdestinations',
58676+
'-json'
58677+
];
58678+
if (!core.isDebug()) {
58679+
core.info(`[command]${xcodebuild} ${destinationArgs.join(' ')}`);
58680+
}
58681+
await (0, exec_1.exec)(xcodebuild, destinationArgs, {
58682+
listeners: {
58683+
stdout: (data) => {
58684+
destinationOutput += data.toString();
58685+
}
58686+
},
58687+
});
58688+
core.info(destinationOutput);
58689+
return `generic/platform=${platform}`;
58690+
}
5866358691
async function getBuildSettings(projectPath, scheme, platform, destination) {
5866458692
let buildSettingsOutput = '';
5866558693
const projectSettingsArgs = [
5866658694
'build',
5866758695
'-project', projectPath,
58668-
'-scheme', scheme
58696+
'-scheme', scheme,
58697+
'-destination', destination,
58698+
'-showBuildSettings'
5866958699
];
58670-
if (destination) {
58671-
projectSettingsArgs.push('-destination', destination);
58672-
}
5867358700
projectSettingsArgs.push('-showBuildSettings');
5867458701
if (!core.isDebug()) {
5867558702
core.info(`[command]${xcodebuild} ${projectSettingsArgs.join(' ')}`);

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/xcode.ts

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
7777
await checkSimulatorsAvailable(platform);
7878
}
7979

80-
const destination = core.getInput('destination');
80+
const destinationInput = core.getInput('destination');
81+
let destination: string;
82+
83+
if (destinationInput) {
84+
destination = destinationInput;
85+
} else {
86+
destination = `generic/platform=${platform}`;
87+
}
88+
8189
core.debug(`Using destination: ${destination}`);
8290
const bundleId = await getBuildSettings(projectPath, scheme, platform, destination);
8391
core.info(`Bundle ID: ${bundleId}`);
@@ -161,6 +169,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
161169
if (projectRef.autoIncrementBuildNumber) {
162170
let projectBundleVersionPrefix = '';
163171
let projectBundleVersionNumber: number;
172+
164173
if (!cFBundleVersion || cFBundleVersion.length === 0) {
165174
projectBundleVersionNumber = 0;
166175
} else if (cFBundleVersion.includes('.')) {
@@ -170,26 +179,29 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
170179
} else {
171180
projectBundleVersionNumber = parseInt(cFBundleVersion);
172181
}
182+
173183
let lastVersionNumber: number;
174184
let versionPrefix = '';
175185
let lastBundleVersion: string = null;
186+
176187
try {
177188
lastBundleVersion = await GetLatestBundleVersion(projectRef);
178189
} catch (error) {
179190
if (error instanceof UnauthorizedError) {
180191
throw error;
181192
}
182193
}
194+
183195
if (!lastBundleVersion || lastBundleVersion.length === 0) {
184196
lastVersionNumber = -1;
185-
}
186-
else if (lastBundleVersion.includes('.')) {
197+
} else if (lastBundleVersion.includes('.')) {
187198
const versionParts = lastBundleVersion.split('.');
188199
lastVersionNumber = parseInt(versionParts[versionParts.length - 1]);
189200
versionPrefix = versionParts.slice(0, -1).join('.') + '.';
190201
} else {
191202
lastVersionNumber = parseInt(lastBundleVersion);
192203
}
204+
193205
if (projectBundleVersionPrefix.length > 0 && projectBundleVersionPrefix !== versionPrefix) {
194206
core.debug(`Project version prefix: ${projectBundleVersionPrefix}`);
195207
core.debug(`Last bundle version prefix: ${versionPrefix}`);
@@ -198,12 +210,15 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
198210
core.info(`Updated project version prefix to: ${projectBundleVersionPrefix}`);
199211
}
200212
}
213+
201214
if (projectBundleVersionNumber <= lastVersionNumber) {
202215
projectBundleVersionNumber = lastVersionNumber + 1;
203216
core.info(`Auto Incremented bundle version ==> ${versionPrefix}${projectBundleVersionNumber}`);
204217
}
218+
205219
infoPlist['CFBundleVersion'] = projectBundleVersionPrefix + projectBundleVersionNumber.toString();
206220
projectRef.bundleVersion = projectBundleVersionPrefix + projectBundleVersionNumber.toString();
221+
207222
try {
208223
await fs.promises.writeFile(infoPlistPath, plist.build(infoPlist));
209224
} catch (error) {
@@ -213,13 +228,15 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
213228
} else {
214229
if (projectRef.platform === 'macOS') {
215230
const notarizeInput = core.getInput('notarize') || 'true';
231+
216232
core.debug(`Notarize input: ${notarizeInput}`);
217233
projectRef.notarize =
218234
notarizeInput === 'true' ||
219235
projectRef.isSteamBuild ||
220236
projectRef.archiveType === 'pkg' ||
221237
projectRef.archiveType === 'dmg';
222238
let output = '';
239+
223240
await exec('security', [
224241
'find-identity',
225242
'-v', projectRef.credential.keychainPath
@@ -231,22 +248,27 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
231248
},
232249
silent: true
233250
});
251+
234252
if (!output.includes('Developer ID Application')) {
235253
throw new Error('Developer ID Application not found! developer-id-application-certificate input is required for notarization.');
236254
}
255+
237256
if (projectRef.archiveType === 'pkg' || projectRef.archiveType === 'dmg') {
238257
if (!output.includes('Developer ID Installer')) {
239258
throw new Error('Developer ID Installer not found! developer-id-installer-certificate input is required for notarization.');
240259
}
241260
}
242261
}
243262
}
263+
244264
const plistHandle = await fs.promises.open(infoPlistPath, fs.constants.O_RDONLY);
265+
245266
try {
246267
infoPlistContent = await fs.promises.readFile(plistHandle, 'utf8');
247268
} finally {
248269
await plistHandle.close();
249270
}
271+
250272
core.info(`------- Info.plist content: -------\n${infoPlistContent}\n-----------------------------------`);
251273
return projectRef;
252274
}
@@ -303,19 +325,44 @@ async function getSupportedPlatform(projectPath: string): Promise<string> {
303325
return platformMap[platformName];
304326
}
305327

328+
async function getDestination(projectPath: string, scheme: string, platform: string): Promise<string> {
329+
let destinationOutput = '';
330+
331+
const destinationArgs = [
332+
'-project', projectPath,
333+
'-scheme', scheme,
334+
'-showdestinations',
335+
'-json'
336+
];
337+
338+
if (!core.isDebug()) {
339+
core.info(`[command]${xcodebuild} ${destinationArgs.join(' ')}`);
340+
}
341+
342+
await exec(xcodebuild, destinationArgs, {
343+
listeners: {
344+
stdout: (data: Buffer) => {
345+
destinationOutput += data.toString();
346+
}
347+
},
348+
});
349+
core.info(destinationOutput);
350+
// example output:
351+
// TODO: parse the output to get the destination
352+
return `generic/platform=${platform}`;
353+
}
354+
306355
async function getBuildSettings(projectPath: string, scheme: string, platform: string, destination: string | undefined): Promise<string> {
307356
let buildSettingsOutput = '';
308357

309358
const projectSettingsArgs = [
310359
'build',
311360
'-project', projectPath,
312-
'-scheme', scheme
361+
'-scheme', scheme,
362+
'-destination', destination,
363+
'-showBuildSettings'
313364
];
314365

315-
if (destination) {
316-
projectSettingsArgs.push('-destination', destination);
317-
}
318-
319366
projectSettingsArgs.push('-showBuildSettings');
320367

321368
if (!core.isDebug()) {

0 commit comments

Comments
 (0)