Skip to content

Commit cc26bbb

Browse files
unity-xcode-builder@v1.2.1
- cleanup duplicate code path when obtaining app id
1 parent 04c0c19 commit cc26bbb

6 files changed

Lines changed: 17 additions & 89 deletions

File tree

dist/index.js

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -57500,7 +57500,7 @@ function checkAuthError(error) {
5750057500
}
5750157501
async function GetAppId(project) {
5750257502
if (project.appId) {
57503-
return project;
57503+
return project.appId;
5750457504
}
5750557505
await getOrCreateClient(project);
5750657506
const { data: response, error } = await appStoreConnectClient.api.AppsService.appsGetCollection({
@@ -57517,7 +57517,7 @@ async function GetAppId(project) {
5751757517
throw new Error(`No apps found for bundle id ${project.bundleId}`);
5751857518
}
5751957519
project.appId = response.data[0].id;
57520-
return project;
57520+
return project.appId;
5752157521
}
5752257522
async function GetLatestBundleVersion(project) {
5752357523
await getOrCreateClient(project);
@@ -57548,7 +57548,7 @@ function reMapPlatform(project) {
5754857548
async function getLastPreReleaseVersionAndBuild(project) {
5754957549
var _a, _b, _c, _d, _e;
5755057550
if (!project.appId) {
57551-
project = await GetAppId(project);
57551+
project.appId = await GetAppId(project);
5755257552
}
5755357553
const preReleaseVersionRequest = {
5755457554
query: {
@@ -58058,10 +58058,10 @@ async function GetProjectDetails(credential, xcodeVersion) {
5805858058
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
5805958059
const cFBundleVersion = infoPlist['CFBundleVersion'];
5806058060
core.info(`CFBundleVersion: ${cFBundleVersion}`);
58061-
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
58061+
let projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
5806258062
await getExportOptions(projectRef);
5806358063
if (projectRef.isAppStoreUpload() && core.getInput('auto-increment-build-number') === 'true') {
58064-
projectRef.credential.appleId = await getAppId(projectRef);
58064+
projectRef.appId = await (0, AppStoreConnectClient_1.GetAppId)(projectRef);
5806558065
let bundleVersion = -1;
5806658066
try {
5806758067
bundleVersion = await (0, AppStoreConnectClient_1.GetLatestBundleVersion)(projectRef);
@@ -58609,42 +58609,6 @@ async function ValidateApp(projectRef) {
5860958609
throw new Error(`Failed to validate app: ${JSON.stringify(JSON.parse(output), null, 2)}`);
5861058610
}
5861158611
}
58612-
async function getAppId(projectRef) {
58613-
const providersArgs = [
58614-
'altool',
58615-
'--list-apps',
58616-
'--apiKey', projectRef.credential.appStoreConnectKeyId,
58617-
'--apiIssuer', projectRef.credential.appStoreConnectIssuerId,
58618-
'--output-format', 'json'
58619-
];
58620-
let output = '';
58621-
if (!core.isDebug()) {
58622-
core.info(`[command]${xcrun} ${providersArgs.join(' ')}`);
58623-
}
58624-
const exitCode = await (0, exec_1.exec)(xcrun, providersArgs, {
58625-
listeners: {
58626-
stdout: (data) => {
58627-
output += data.toString();
58628-
}
58629-
},
58630-
ignoreReturnCode: true,
58631-
silent: !core.isDebug()
58632-
});
58633-
const response = JSON.parse(output);
58634-
const outputJson = JSON.stringify(response, null, 2);
58635-
if (exitCode > 0) {
58636-
(0, utilities_1.log)(outputJson, 'error');
58637-
throw new Error(`Failed to list providers`);
58638-
}
58639-
const app = response.applications.find((app) => app.ExistingBundleIdentifier === projectRef.bundleId);
58640-
if (!app) {
58641-
throw new Error(`App not found with bundleId: ${projectRef.bundleId}`);
58642-
}
58643-
if (!app.AppleID) {
58644-
throw new Error(`AppleID not found for app: ${JSON.stringify(app, null, 2)}`);
58645-
}
58646-
return app.AppleID;
58647-
}
5864858612
async function UploadApp(projectRef) {
5864958613
const platforms = {
5865058614
'iOS': 'ios',

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.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-xcode-builder",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "A GitHub Action to build, archive, and upload Unity exported xcode projects.",
55
"author": "buildalon",
66
"license": "MIT",

src/AppStoreConnectClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function checkAuthError(error: any) {
4848
}
4949
}
5050

51-
export async function GetAppId(project: XcodeProject): Promise<XcodeProject> {
52-
if (project.appId) { return project; }
51+
export async function GetAppId(project: XcodeProject): Promise<string> {
52+
if (project.appId) { return project.appId; }
5353
await getOrCreateClient(project);
5454
const { data: response, error } = await appStoreConnectClient.api.AppsService.appsGetCollection({
5555
query: { 'filter[bundleId]': [project.bundleId] }
@@ -65,7 +65,7 @@ export async function GetAppId(project: XcodeProject): Promise<XcodeProject> {
6565
throw new Error(`No apps found for bundle id ${project.bundleId}`);
6666
}
6767
project.appId = response.data[0].id;
68-
return project;
68+
return project.appId;
6969
}
7070

7171
export async function GetLatestBundleVersion(project: XcodeProject): Promise<number> {
@@ -97,7 +97,7 @@ function reMapPlatform(project: XcodeProject): ('IOS' | 'MAC_OS' | 'TV_OS' | 'VI
9797
}
9898

9999
async function getLastPreReleaseVersionAndBuild(project: XcodeProject): Promise<PreReleaseVersionWithBuild> {
100-
if (!project.appId) { project = await GetAppId(project); }
100+
if (!project.appId) { project.appId = await GetAppId(project); }
101101
const preReleaseVersionRequest: PreReleaseVersionsGetCollectionData = {
102102
query: {
103103
'filter[app]': [project.appId],

src/xcode.ts

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import semver = require('semver');
1010
import {
1111
GetLatestBundleVersion,
1212
UpdateTestDetails,
13-
UnauthorizedError
13+
UnauthorizedError,
14+
GetAppId
1415
} from './AppStoreConnectClient';
1516
import { log } from './utilities';
1617
import core = require('@actions/core');
@@ -80,7 +81,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
8081
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
8182
const cFBundleVersion = infoPlist['CFBundleVersion'] as number;
8283
core.info(`CFBundleVersion: ${cFBundleVersion}`);
83-
const projectRef = new XcodeProject(
84+
let projectRef = new XcodeProject(
8485
projectPath,
8586
projectName,
8687
platform,
@@ -95,7 +96,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
9596
);
9697
await getExportOptions(projectRef);
9798
if (projectRef.isAppStoreUpload() && core.getInput('auto-increment-build-number') === 'true') {
98-
projectRef.credential.appleId = await getAppId(projectRef);
99+
projectRef.appId = await GetAppId(projectRef);
99100
let bundleVersion = -1;
100101
try {
101102
bundleVersion = await GetLatestBundleVersion(projectRef);
@@ -646,43 +647,6 @@ export async function ValidateApp(projectRef: XcodeProject) {
646647
}
647648
}
648649

649-
async function getAppId(projectRef: XcodeProject): Promise<string> {
650-
const providersArgs = [
651-
'altool',
652-
'--list-apps',
653-
'--apiKey', projectRef.credential.appStoreConnectKeyId,
654-
'--apiIssuer', projectRef.credential.appStoreConnectIssuerId,
655-
'--output-format', 'json'
656-
];
657-
let output = '';
658-
if (!core.isDebug()) {
659-
core.info(`[command]${xcrun} ${providersArgs.join(' ')}`);
660-
}
661-
const exitCode = await exec(xcrun, providersArgs, {
662-
listeners: {
663-
stdout: (data: Buffer) => {
664-
output += data.toString();
665-
}
666-
},
667-
ignoreReturnCode: true,
668-
silent: !core.isDebug()
669-
});
670-
const response = JSON.parse(output);
671-
const outputJson = JSON.stringify(response, null, 2);
672-
if (exitCode > 0) {
673-
log(outputJson, 'error');
674-
throw new Error(`Failed to list providers`);
675-
}
676-
const app = response.applications.find((app: any) => app.ExistingBundleIdentifier === projectRef.bundleId);
677-
if (!app) {
678-
throw new Error(`App not found with bundleId: ${projectRef.bundleId}`);
679-
}
680-
if (!app.AppleID) {
681-
throw new Error(`AppleID not found for app: ${JSON.stringify(app, null, 2)}`);
682-
}
683-
return app.AppleID;
684-
}
685-
686650
export async function UploadApp(projectRef: XcodeProject) {
687651
const platforms = {
688652
'iOS': 'ios',

0 commit comments

Comments
 (0)