Skip to content

Commit 54ccf3d

Browse files
unity-xcode-builder@v1.3.4
- add derived data input arg - setup and use ccache to speed up builds
1 parent 9716df2 commit 54ccf3d

9 files changed

Lines changed: 84 additions & 27 deletions

File tree

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ inputs:
114114
developer-id-installer-certificate-password:
115115
description: The password for the `Developer ID Installer` certificate. Required if `developer-id-installer-certificate` is provided.
116116
required: false
117+
derived-data-path:
118+
description: The path to use for Xcode DerivedData. Defaults to a sibling 'DerivedData' directory next to the .xcodeproj.
119+
required: false
117120
outputs:
118121
executable:
119122
description: The path to the generated archive executable.

dist/index.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4803,13 +4803,28 @@ var import_graphql = __nccwpck_require__(8467);
48034803
var import_auth_token = __nccwpck_require__(334);
48044804

48054805
// pkg/dist-src/version.js
4806-
var VERSION = "5.2.1";
4806+
var VERSION = "5.2.2";
48074807

48084808
// pkg/dist-src/index.js
48094809
var noop = () => {
48104810
};
48114811
var consoleWarn = console.warn.bind(console);
48124812
var consoleError = console.error.bind(console);
4813+
function createLogger(logger = {}) {
4814+
if (typeof logger.debug !== "function") {
4815+
logger.debug = noop;
4816+
}
4817+
if (typeof logger.info !== "function") {
4818+
logger.info = noop;
4819+
}
4820+
if (typeof logger.warn !== "function") {
4821+
logger.warn = consoleWarn;
4822+
}
4823+
if (typeof logger.error !== "function") {
4824+
logger.error = consoleError;
4825+
}
4826+
return logger;
4827+
}
48134828
var userAgentTrail = `octokit-core.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`;
48144829
var Octokit = class {
48154830
static {
@@ -4883,15 +4898,7 @@ var Octokit = class {
48834898
}
48844899
this.request = import_request.request.defaults(requestDefaults);
48854900
this.graphql = (0, import_graphql.withCustomRequest)(this.request).defaults(requestDefaults);
4886-
this.log = Object.assign(
4887-
{
4888-
debug: noop,
4889-
info: noop,
4890-
warn: consoleWarn,
4891-
error: consoleError
4892-
},
4893-
options.log
4894-
);
4901+
this.log = createLogger(options.log);
48954902
this.hook = hook;
48964903
if (!options.authStrategy) {
48974904
if (!options.auth) {
@@ -58286,7 +58293,7 @@ async function unlockTemporaryKeychain(keychainPath, tempCredential) {
5828658293
Object.defineProperty(exports, "__esModule", ({ value: true }));
5828758294
exports.XcodeProject = void 0;
5828858295
class XcodeProject {
58289-
constructor(projectPath, projectName, platform, destination, bundleId, projectDirectory, versionString, bundleVersion, scheme, credential, xcodeVersion) {
58296+
constructor(projectPath, projectName, platform, destination, bundleId, projectDirectory, versionString, bundleVersion, scheme, credential, xcodeVersion, derivedDataPath) {
5829058297
this.projectPath = projectPath;
5829158298
this.projectName = projectName;
5829258299
this.platform = platform;
@@ -58299,6 +58306,7 @@ class XcodeProject {
5829958306
this.credential = credential;
5830058307
this.xcodeVersion = xcodeVersion;
5830158308
this.isSteamBuild = false;
58309+
this.derivedDataPath = derivedDataPath;
5830258310
}
5830358311
isAppStoreUpload() {
5830458312
return this.exportOption === 'app-store' || this.exportOption === 'app-store-connect';
@@ -58317,7 +58325,9 @@ exports.XcodeProject = XcodeProject;
5831758325
Object.defineProperty(exports, "__esModule", ({ value: true }));
5831858326
exports.log = log;
5831958327
exports.DeepEqual = DeepEqual;
58328+
exports.SetupCCache = SetupCCache;
5832058329
const core = __nccwpck_require__(2186);
58330+
const exec_1 = __nccwpck_require__(1514);
5832158331
function log(message, type = 'info') {
5832258332
if (type == 'info' && !core.isDebug()) {
5832358333
return;
@@ -58376,6 +58386,19 @@ function DeepEqual(a, b) {
5837658386
}
5837758387
return true;
5837858388
}
58389+
async function SetupCCache() {
58390+
try {
58391+
await (0, exec_1.exec)('which', ['ccache'], {
58392+
failOnStdErr: true
58393+
});
58394+
}
58395+
catch (_a) {
58396+
await (0, exec_1.exec)('brew', ['install', 'ccache']);
58397+
}
58398+
process.env.CC = 'ccache clang';
58399+
process.env.CXX = 'ccache clang++';
58400+
core.info('ccache is enabled for Xcode builds.');
58401+
}
5837958402

5838058403

5838158404
/***/ }),
@@ -58490,7 +58513,9 @@ async function GetProjectDetails(credential, xcodeVersion) {
5849058513
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
5849158514
const cFBundleVersion = infoPlist['CFBundleVersion'];
5849258515
core.info(`CFBundleVersion: ${cFBundleVersion}`);
58493-
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
58516+
const derivedDataPathInput = core.getInput('derived-data-path') || path.join(projectDirectory, 'DerivedData');
58517+
core.debug(`DerivedData path input: ${derivedDataPathInput}`);
58518+
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion, derivedDataPathInput);
5849458519
projectRef.autoIncrementBuildNumber = core.getInput('auto-increment-build-number') === 'true';
5849558520
await getExportOptions(projectRef);
5849658521
if (projectRef.isAppStoreUpload()) {
@@ -58745,6 +58770,7 @@ async function ArchiveXcodeProject(projectRef) {
5874558770
'-destination', projectRef.destination,
5874658771
'-configuration', configuration,
5874758772
'-archivePath', archivePath,
58773+
`-derivedDataPath`, projectRef.derivedDataPath,
5874858774
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,
5874958775
`-authenticationKeyPath`, projectRef.credential.appStoreConnectKeyPath,
5875058776
`-authenticationKeyIssuerID`, projectRef.credential.appStoreConnectIssuerId
@@ -58809,6 +58835,7 @@ async function ExportXcodeArchive(projectRef) {
5880958835
'-archivePath', archivePath,
5881058836
'-exportPath', projectRef.exportPath,
5881158837
'-exportOptionsPlist', exportOptionsPath,
58838+
`-derivedDataPath`, projectRef.derivedDataPath,
5881258839
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,
5881358840
`-authenticationKeyPath`, projectRef.credential.appStoreConnectKeyPath,
5881458841
`-authenticationKeyIssuerID`, projectRef.credential.appStoreConnectIssuerId
@@ -61481,6 +61508,7 @@ const exec = __nccwpck_require__(1514);
6148161508
const xcode_1 = __nccwpck_require__(9157);
6148261509
const AppleCredential_1 = __nccwpck_require__(4199);
6148361510
const semver = __nccwpck_require__(1383);
61511+
const utilities_1 = __nccwpck_require__(5739);
6148461512
const IS_POST = !!core.getState('isPost');
6148561513
const main = async () => {
6148661514
try {
@@ -61562,6 +61590,7 @@ const main = async () => {
6156261590
if (xcodeVersionString !== selectedXcodeVersionString) {
6156361591
throw new Error(`Selected Xcode version ${selectedXcodeVersionString} does not match requested version ${xcodeVersionString}!`);
6156461592
}
61593+
await (0, utilities_1.SetupCCache)();
6156561594
let projectRef = await (0, xcode_1.GetProjectDetails)(credential, semver.coerce(xcodeVersionString));
6156661595
projectRef = await (0, xcode_1.ArchiveXcodeProject)(projectRef);
6156761596
projectRef = await (0, xcode_1.ExportXcodeArchive)(projectRef);

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: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-xcode-builder",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
44
"description": "A GitHub Action to build, archive, and upload Unity exported xcode projects.",
55
"author": "buildalon",
66
"license": "MIT",
@@ -25,7 +25,7 @@
2525
"uuid": "^10.0.0"
2626
},
2727
"devDependencies": {
28-
"@types/node": "^22.15.33",
28+
"@types/node": "^22.16.5",
2929
"@types/plist": "^3.0.5",
3030
"@types/semver": "^7.7.0",
3131
"@types/uuid": "^10.0.0",
@@ -39,4 +39,4 @@
3939
"watch": "ncc build src/index.ts -o dist --source-map --license licenses.txt --watch",
4040
"clean": "npm install && shx rm -rf dist/ out/ node_modules/ && npm ci"
4141
}
42-
}
42+
}

src/XcodeProject.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export class XcodeProject {
1313
bundleVersion: string,
1414
scheme: string,
1515
credential: AppleCredential,
16-
xcodeVersion: SemVer
16+
xcodeVersion: SemVer,
17+
derivedDataPath: string,
1718
) {
1819
this.projectPath = projectPath;
1920
this.projectName = projectName;
@@ -27,6 +28,7 @@ export class XcodeProject {
2728
this.credential = credential
2829
this.xcodeVersion = xcodeVersion;
2930
this.isSteamBuild = false;
31+
this.derivedDataPath = derivedDataPath;
3032
}
3133
projectPath: string;
3234
projectName: string;
@@ -50,6 +52,7 @@ export class XcodeProject {
5052
isSteamBuild: boolean;
5153
archiveType: string;
5254
notarize: boolean;
55+
derivedDataPath: string;
5356
isAppStoreUpload(): boolean {
5457
return this.exportOption === 'app-store' || this.exportOption === 'app-store-connect';
5558
}

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
RemoveCredentials
1313
} from './AppleCredential';
1414
import semver = require('semver');
15+
import { SetupCCache } from './utilities';
1516

1617
const IS_POST = !!core.getState('isPost');
1718

@@ -93,6 +94,7 @@ const main = async () => {
9394
if (xcodeVersionString !== selectedXcodeVersionString) {
9495
throw new Error(`Selected Xcode version ${selectedXcodeVersionString} does not match requested version ${xcodeVersionString}!`);
9596
}
97+
await SetupCCache();
9698
let projectRef = await GetProjectDetails(credential, semver.coerce(xcodeVersionString));
9799
projectRef = await ArchiveXcodeProject(projectRef);
98100
projectRef = await ExportXcodeArchive(projectRef);

src/utilities.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import core = require('@actions/core');
3+
import { exec } from '@actions/exec';
34

45
export function log(message: string, type: 'info' | 'warning' | 'error' = 'info') {
56
if (type == 'info' && !core.isDebug()) { return; }
@@ -49,4 +50,18 @@ export function DeepEqual(a: any, b: any): boolean {
4950
if (!DeepEqual(a[key], b[key])) return false;
5051
}
5152
return true;
53+
}
54+
55+
export async function SetupCCache() {
56+
try {
57+
await exec('which', ['ccache'], {
58+
failOnStdErr: true
59+
});
60+
} catch {
61+
await exec('brew', ['install', 'ccache']);
62+
}
63+
// Set environment variables for ccache
64+
process.env.CC = 'ccache clang';
65+
process.env.CXX = 'ccache clang++';
66+
core.info('ccache is enabled for Xcode builds.');
5267
}

src/xcode.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
107107
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
108108
const cFBundleVersion = infoPlist['CFBundleVersion'] as string;
109109
core.info(`CFBundleVersion: ${cFBundleVersion}`);
110+
const derivedDataPathInput = core.getInput('derived-data-path') || path.join(projectDirectory, 'DerivedData');
111+
core.debug(`DerivedData path input: ${derivedDataPathInput}`);
110112
const projectRef = new XcodeProject(
111113
projectPath,
112114
projectName,
@@ -118,7 +120,8 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
118120
cFBundleVersion,
119121
scheme,
120122
credential,
121-
xcodeVersion
123+
xcodeVersion,
124+
derivedDataPathInput
122125
);
123126
projectRef.autoIncrementBuildNumber = core.getInput('auto-increment-build-number') === 'true';
124127
await getExportOptions(projectRef);
@@ -370,6 +373,7 @@ export async function ArchiveXcodeProject(projectRef: XcodeProject): Promise<Xco
370373
'-destination', projectRef.destination,
371374
'-configuration', configuration,
372375
'-archivePath', archivePath,
376+
`-derivedDataPath`, projectRef.derivedDataPath,
373377
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,
374378
`-authenticationKeyPath`, projectRef.credential.appStoreConnectKeyPath,
375379
`-authenticationKeyIssuerID`, projectRef.credential.appStoreConnectIssuerId
@@ -442,6 +446,7 @@ export async function ExportXcodeArchive(projectRef: XcodeProject): Promise<Xcod
442446
'-archivePath', archivePath,
443447
'-exportPath', projectRef.exportPath,
444448
'-exportOptionsPlist', exportOptionsPath,
449+
`-derivedDataPath`, projectRef.derivedDataPath,
445450
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,
446451
`-authenticationKeyPath`, projectRef.credential.appStoreConnectKeyPath,
447452
`-authenticationKeyIssuerID`, projectRef.credential.appStoreConnectIssuerId

0 commit comments

Comments
 (0)