Skip to content

Commit 5214ec7

Browse files
add build step before archive step
1 parent 3298819 commit 5214ec7

5 files changed

Lines changed: 160 additions & 83 deletions

File tree

dist/index.js

Lines changed: 78 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58293,11 +58293,15 @@ async function unlockTemporaryKeychain(keychainPath, tempCredential) {
5829358293
Object.defineProperty(exports, "__esModule", ({ value: true }));
5829458294
exports.XcodeProject = void 0;
5829558295
class XcodeProject {
58296-
constructor(projectPath, projectName, platform, destination, bundleId, projectDirectory, versionString, bundleVersion, scheme, credential, xcodeVersion) {
58296+
constructor(projectPath, projectName, platform, destination, configuration, bundleId, projectDirectory, versionString, bundleVersion, scheme, credential, xcodeVersion) {
58297+
this.entitlementsPath = null;
5829758298
this.projectPath = projectPath;
5829858299
this.projectName = projectName;
5829958300
this.platform = platform;
5830058301
this.destination = destination;
58302+
this.configuration = configuration;
58303+
this.archivePath = `${this.projectDirectory}/${this.projectName}.xcarchive`;
58304+
this.exportPath = `${this.projectDirectory}/${this.projectName}`;
5830158305
this.bundleId = bundleId;
5830258306
this.projectDirectory = projectDirectory;
5830358307
this.versionString = versionString;
@@ -58455,6 +58459,7 @@ async function SetupCCache() {
5845558459

5845658460
Object.defineProperty(exports, "__esModule", ({ value: true }));
5845758461
exports.GetProjectDetails = GetProjectDetails;
58462+
exports.BuildXcodeProject = BuildXcodeProject;
5845858463
exports.ArchiveXcodeProject = ArchiveXcodeProject;
5845958464
exports.ExportXcodeArchive = ExportXcodeArchive;
5846058465
exports.isAppBundleNotarized = isAppBundleNotarized;
@@ -58561,8 +58566,19 @@ async function GetProjectDetails(credential, xcodeVersion) {
5856158566
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
5856258567
const cFBundleVersion = infoPlist['CFBundleVersion'];
5856358568
core.info(`CFBundleVersion: ${cFBundleVersion}`);
58564-
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
58569+
const configuration = core.getInput('configuration') || 'Release';
58570+
core.debug(`Configuration: ${configuration}`);
58571+
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, configuration, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
5856558572
projectRef.autoIncrementBuildNumber = core.getInput('auto-increment-build-number') === 'true';
58573+
let entitlementsPath = core.getInput('entitlements-plist');
58574+
if (!entitlementsPath) {
58575+
if (projectRef.platform === 'macOS') {
58576+
projectRef.entitlementsPath = await getDefaultEntitlementsMacOS(projectRef);
58577+
}
58578+
}
58579+
else {
58580+
projectRef.entitlementsPath = entitlementsPath;
58581+
}
5856658582
await getExportOptions(projectRef);
5856758583
if (projectRef.isAppStoreUpload()) {
5856858584
projectRef.appId = await (0, AppStoreConnectClient_1.GetAppId)(projectRef);
@@ -58826,31 +58842,54 @@ async function downloadPlatformSdkIfMissing(platform, version) {
5882658842
await (0, exec_1.exec)('xcodes', ['runtimes', 'install', `${platform} ${version}`]);
5882758843
}
5882858844
}
58829-
async function ArchiveXcodeProject(projectRef) {
58830-
const { projectPath, projectName, projectDirectory } = projectRef;
58831-
const archivePath = `${projectDirectory}/${projectName}.xcarchive`;
58832-
core.debug(`Archive path: ${archivePath}`);
58845+
async function BuildXcodeProject(projectRef) {
58846+
const { projectPath, scheme, destination, platform, projectDirectory } = projectRef;
5883358847
const configuration = core.getInput('configuration') || 'Release';
58834-
core.debug(`Configuration: ${configuration}`);
58835-
let entitlementsPath = core.getInput('entitlements-plist');
58836-
if (!entitlementsPath && projectRef.platform === 'macOS') {
58837-
await getDefaultEntitlementsMacOS(projectRef);
58848+
const buildArgs = [
58849+
'build',
58850+
'-project', projectPath,
58851+
'-scheme', scheme,
58852+
'-destination', destination,
58853+
'-configuration', configuration,
58854+
'-derivedDataPath', `${projectDirectory}/DerivedData`,
58855+
'CODE_SIGN_IDENTITY=-',
58856+
'CODE_SIGNING_REQUIRED=NO',
58857+
'CODE_SIGNING_ALLOWED=NO'
58858+
];
58859+
if (platform === 'iOS') {
58860+
buildArgs.push('COPY_PHASE_STRIP=NO');
58861+
}
58862+
if (platform === 'macOS' && !projectRef.isAppStoreUpload()) {
58863+
buildArgs.push('ENABLE_HARDENED_RUNTIME=YES');
58864+
}
58865+
if (!core.isDebug()) {
58866+
buildArgs.push('-quiet');
5883858867
}
5883958868
else {
58840-
projectRef.entitlementsPath = entitlementsPath;
58869+
buildArgs.push('-verbose');
58870+
}
58871+
if (core.isDebug()) {
58872+
await execXcodeBuild(buildArgs);
5884158873
}
58842-
const { teamId, manualSigningIdentity, manualProvisioningProfileUUID, keychainPath } = projectRef.credential;
58874+
else {
58875+
await execWithXcBeautify(buildArgs);
58876+
}
58877+
return projectRef;
58878+
}
58879+
async function ArchiveXcodeProject(projectRef) {
58880+
const { projectPath, scheme, platform, destination, configuration, archivePath, entitlementsPath, projectDirectory, credential } = projectRef;
58881+
const { teamId, manualSigningIdentity, manualProvisioningProfileUUID, keychainPath } = credential;
5884358882
const archiveArgs = [
5884458883
'archive',
5884558884
'-project', projectPath,
58846-
'-scheme', projectRef.scheme,
58847-
'-destination', projectRef.destination,
58885+
'-scheme', scheme,
58886+
'-destination', destination,
5884858887
'-configuration', configuration,
5884958888
'-archivePath', archivePath,
5885058889
'-derivedDataPath', `${projectDirectory}/DerivedData`,
58851-
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,
58852-
`-authenticationKeyPath`, projectRef.credential.appStoreConnectKeyPath,
58853-
`-authenticationKeyIssuerID`, projectRef.credential.appStoreConnectIssuerId
58890+
`-authenticationKeyID`, credential.appStoreConnectKeyId,
58891+
`-authenticationKeyPath`, credential.appStoreConnectKeyPath,
58892+
`-authenticationKeyIssuerID`, credential.appStoreConnectIssuerId
5885458893
];
5885558894
if (teamId) {
5885658895
archiveArgs.push(`DEVELOPMENT_TEAM=${teamId}`);
@@ -58868,22 +58907,22 @@ async function ArchiveXcodeProject(projectRef) {
5886858907
else {
5886958908
archiveArgs.push(`AD_HOC_CODE_SIGNING_ALLOWED=YES`, `-allowProvisioningUpdates`);
5887058909
}
58871-
if (projectRef.entitlementsPath) {
58872-
core.debug(`Entitlements path: ${projectRef.entitlementsPath}`);
58873-
const entitlementsHandle = await fs.promises.open(projectRef.entitlementsPath, fs.constants.O_RDONLY);
58910+
if (entitlementsPath) {
58911+
core.debug(`Entitlements path: ${entitlementsPath}`);
58912+
const entitlementsHandle = await fs.promises.open(entitlementsPath, fs.constants.O_RDONLY);
5887458913
try {
5887558914
const entitlementsContent = await fs.promises.readFile(entitlementsHandle, 'utf8');
5887658915
core.info(`----- Entitlements content: -----\n${entitlementsContent}\n-----------------------------------`);
5887758916
}
5887858917
finally {
5887958918
await entitlementsHandle.close();
5888058919
}
58881-
archiveArgs.push(`CODE_SIGN_ENTITLEMENTS=${projectRef.entitlementsPath}`);
58920+
archiveArgs.push(`CODE_SIGN_ENTITLEMENTS=${entitlementsPath}`);
5888258921
}
58883-
if (projectRef.platform === 'iOS') {
58922+
if (platform === 'iOS') {
5888458923
archiveArgs.push('COPY_PHASE_STRIP=NO');
5888558924
}
58886-
if (projectRef.platform === 'macOS' && !projectRef.isAppStoreUpload()) {
58925+
if (platform === 'macOS' && !projectRef.isAppStoreUpload()) {
5888758926
archiveArgs.push('ENABLE_HARDENED_RUNTIME=YES');
5888858927
}
5888958928
if (!core.isDebug()) {
@@ -58898,25 +58937,22 @@ async function ArchiveXcodeProject(projectRef) {
5889858937
else {
5889958938
await execWithXcBeautify(archiveArgs);
5890058939
}
58901-
projectRef.archivePath = archivePath;
5890258940
return projectRef;
5890358941
}
5890458942
async function ExportXcodeArchive(projectRef) {
58905-
const { projectName, projectDirectory, archivePath, exportOptionsPath } = projectRef;
58906-
projectRef.exportPath = `${projectDirectory}/${projectName}`;
58907-
core.debug(`Export path: ${projectRef.exportPath}`);
58908-
core.setOutput('output-directory', projectRef.exportPath);
58909-
const { manualProvisioningProfileUUID } = projectRef.credential;
58943+
const { platform, archivePath, exportPath, exportOptionsPath, credential } = projectRef;
58944+
core.debug(`Export path: ${exportPath}`);
58945+
core.setOutput('output-directory', exportPath);
5891058946
const exportArgs = [
5891158947
'-exportArchive',
5891258948
'-archivePath', archivePath,
58913-
'-exportPath', projectRef.exportPath,
58949+
'-exportPath', exportPath,
5891458950
'-exportOptionsPlist', exportOptionsPath,
58915-
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,
58916-
`-authenticationKeyPath`, projectRef.credential.appStoreConnectKeyPath,
58917-
`-authenticationKeyIssuerID`, projectRef.credential.appStoreConnectIssuerId
58951+
`-authenticationKeyID`, credential.appStoreConnectKeyId,
58952+
`-authenticationKeyPath`, credential.appStoreConnectKeyPath,
58953+
`-authenticationKeyIssuerID`, credential.appStoreConnectIssuerId
5891858954
];
58919-
if (!manualProvisioningProfileUUID) {
58955+
if (!credential.manualProvisioningProfileUUID) {
5892058956
exportArgs.push(`-allowProvisioningUpdates`);
5892158957
}
5892258958
if (!core.isDebug()) {
@@ -58931,15 +58967,15 @@ async function ExportXcodeArchive(projectRef) {
5893158967
else {
5893258968
await execWithXcBeautify(exportArgs);
5893358969
}
58934-
if (projectRef.platform === 'macOS') {
58970+
if (platform === 'macOS') {
5893558971
if (!projectRef.isAppStoreUpload()) {
58936-
projectRef.executablePath = await getFirstPathWithGlob(`${projectRef.exportPath}/**/*.app`);
58972+
projectRef.executablePath = await getFirstPathWithGlob(`${exportPath}/**/*.app`);
5893758973
if (projectRef.notarize) {
5893858974
await signMacOSAppBundle(projectRef);
5893958975
if (projectRef.isSteamBuild) {
5894058976
const isNotarized = await isAppBundleNotarized(projectRef.executablePath);
5894158977
if (!isNotarized) {
58942-
const zipPath = path.join(projectRef.exportPath, projectRef.executablePath.replace('.app', '.zip'));
58978+
const zipPath = path.join(exportPath, projectRef.executablePath.replace('.app', '.zip'));
5894358979
await (0, exec_1.exec)('ditto', ['-c', '-k', '--sequesterRsrc', '--keepParent', projectRef.executablePath, zipPath]);
5894458980
await notarizeArchive(projectRef, zipPath, projectRef.executablePath);
5894558981
}
@@ -58956,11 +58992,11 @@ async function ExportXcodeArchive(projectRef) {
5895658992
}
5895758993
}
5895858994
else {
58959-
projectRef.executablePath = await getFirstPathWithGlob(`${projectRef.exportPath}/**/*.pkg`);
58995+
projectRef.executablePath = await getFirstPathWithGlob(`${exportPath}/**/*.pkg`);
5896058996
}
5896158997
}
5896258998
else {
58963-
projectRef.executablePath = await getFirstPathWithGlob(`${projectRef.exportPath}/**/*.ipa`);
58999+
projectRef.executablePath = await getFirstPathWithGlob(`${exportPath}/**/*.ipa`);
5896459000
}
5896559001
try {
5896659002
await fs.promises.access(projectRef.executablePath, fs.constants.R_OK);
@@ -59367,11 +59403,10 @@ async function getExportOptions(projectRef) {
5936759403
}
5936859404
async function getDefaultEntitlementsMacOS(projectRef) {
5936959405
const entitlementsPath = `${projectRef.projectPath}/Entitlements.plist`;
59370-
projectRef.entitlementsPath = entitlementsPath;
5937159406
try {
5937259407
await fs.promises.access(entitlementsPath, fs.constants.R_OK);
5937359408
core.debug(`Existing Entitlements.plist found at: ${entitlementsPath}`);
59374-
return;
59409+
return entitlementsPath;
5937559410
}
5937659411
catch (error) {
5937759412
core.warning('Entitlements.plist not found, creating default Entitlements.plist...');
@@ -59397,6 +59432,7 @@ async function getDefaultEntitlementsMacOS(projectRef) {
5939759432
break;
5939859433
}
5939959434
await fs.promises.writeFile(entitlementsPath, plist.build(defaultEntitlements));
59435+
return entitlementsPath;
5940059436
}
5940159437
async function execXcodeBuild(xcodeBuildArgs) {
5940259438
let output = '';
@@ -61667,6 +61703,7 @@ const main = async () => {
6166761703
throw new Error(`Selected Xcode version ${selectedXcodeVersionString} does not match requested version ${xcodeVersionString}!`);
6166861704
}
6166961705
let projectRef = await (0, xcode_1.GetProjectDetails)(credential, semver.coerce(xcodeVersionString));
61706+
projectRef = await (0, xcode_1.BuildXcodeProject)(projectRef);
6167061707
projectRef = await (0, xcode_1.ArchiveXcodeProject)(projectRef);
6167161708
projectRef = await (0, xcode_1.ExportXcodeArchive)(projectRef);
6167261709
const uploadInput = core.getInput('upload') || projectRef.isAppStoreUpload().toString();

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/XcodeProject.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class XcodeProject {
77
projectName: string,
88
platform: string,
99
destination: string,
10+
configuration: string,
1011
bundleId: string,
1112
projectDirectory: string,
1213
versionString: string,
@@ -19,6 +20,9 @@ export class XcodeProject {
1920
this.projectName = projectName;
2021
this.platform = platform;
2122
this.destination = destination;
23+
this.configuration = configuration;
24+
this.archivePath = `${this.projectDirectory}/${this.projectName}.xcarchive`;
25+
this.exportPath = `${this.projectDirectory}/${this.projectName}`;
2226
this.bundleId = bundleId;
2327
this.projectDirectory = projectDirectory;
2428
this.versionString = versionString;
@@ -36,12 +40,13 @@ export class XcodeProject {
3640
credential: AppleCredential;
3741
platform: string;
3842
destination: string;
43+
configuration: string;
3944
archivePath: string;
4045
exportPath: string;
4146
executablePath: string;
4247
exportOption: string;
4348
exportOptionsPath: string;
44-
entitlementsPath: string;
49+
entitlementsPath: string | null = null;
4550
versionString: string;
4651
bundleVersion: string;
4752
scheme: string;

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import core = require('@actions/core');
22
import exec = require('@actions/exec');
33
import {
44
GetProjectDetails,
5+
BuildXcodeProject,
56
ArchiveXcodeProject,
67
ExportXcodeArchive,
78
ValidateApp,
89
UploadApp
910
} from './xcode';
11+
1012
import {
1113
ImportCredentials,
1214
RemoveCredentials
@@ -94,6 +96,8 @@ const main = async () => {
9496
throw new Error(`Selected Xcode version ${selectedXcodeVersionString} does not match requested version ${xcodeVersionString}!`);
9597
}
9698
let projectRef = await GetProjectDetails(credential, semver.coerce(xcodeVersionString));
99+
// Run a build step before archiving to catch errors early and generate intermediate artifacts
100+
projectRef = await BuildXcodeProject(projectRef);
97101
projectRef = await ArchiveXcodeProject(projectRef);
98102
projectRef = await ExportXcodeArchive(projectRef);
99103
const uploadInput = core.getInput('upload') || projectRef.isAppStoreUpload().toString();

0 commit comments

Comments
 (0)