Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"xcode-version": [
"16.3",
"16.4"
""
],
"exclude": [
{
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@
- run: openupm add com.virtualmaker.buildalon
name: Add Build Pipeline Package
working-directory: ${{ env.UNITY_PROJECT_PATH }}
- uses: buildalon/unity-action@v1
- uses: buildalon/unity-action@v2
name: '${{ matrix.build-target }}-Validate'
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Validate'
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
- uses: buildalon/unity-action@v1
- uses: buildalon/unity-action@v2
name: '${{ matrix.build-target }}-Build'
with:
build-target: ${{ matrix.build-target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
push:
branches: ['main']
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches: ['*']
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
72 changes: 40 additions & 32 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58506,46 +58506,54 @@ const xcodebuild = '/usr/bin/xcodebuild';
const xcrun = '/usr/bin/xcrun';
const WORKSPACE = process.env.GITHUB_WORKSPACE || process.cwd();
async function GetOrSetXcodeVersion() {
let xcodeVersionString = core.getInput('xcode-version');
if (xcodeVersionString) {
core.info(`Setting xcode version to ${xcodeVersionString}`);
let xcodeVersionOutput = '';
const installedExitCode = await (0, exec_1.exec)('xcodes', ['installed'], {
listeners: {
stdout: (data) => {
xcodeVersionOutput += data.toString();
}
}
});
if (installedExitCode !== 0) {
throw new Error('Failed to get installed Xcode versions!');
}
const installedXcodeVersions = xcodeVersionOutput.split('\n').map(line => {
const match = line.match(/(\d+\.\d+(\s\w+)?)/);
return match ? match[1] : null;
}).filter(Boolean);
core.info(`Installed Xcode versions:`);
installedXcodeVersions.forEach(version => core.info(` > ${version}`));
if (installedXcodeVersions.length === 0 || !xcodeVersionString.includes('latest')) {
if (installedXcodeVersions.length === 0 || !installedXcodeVersions.includes(xcodeVersionString)) {
throw new Error(`Xcode version ${xcodeVersionString} is not installed! You will need to install this is a step before this one.`);
let xcodeVersionString = core.getInput('xcode-version') || 'latest';
core.info(`Setting xcode version to ${xcodeVersionString}`);
let xcodeVersionOutput = '';
const installedExitCode = await (0, exec_1.exec)('xcodes', ['installed'], {
listeners: {
stdout: (data) => {
xcodeVersionOutput += data.toString();
}
}
else {
const nonBetaVersions = installedXcodeVersions.filter(v => !/Beta/i.test(v));
if (nonBetaVersions.length === 0) {
throw new Error('No Xcode versions installed!');
}
xcodeVersionString = nonBetaVersions[nonBetaVersions.length - 1];
});
if (installedExitCode !== 0) {
throw new Error('Failed to get installed Xcode versions!');
}
const installedLines = xcodeVersionOutput.split('\n').filter(l => l.trim().length > 0);
const installedXcodeEntries = installedLines.map(line => {
const match = line.match(/^(\d+\.\d+)/);
if (!match) {
return null;
}
const version = match[1];
const isBeta = /Beta/i.test(line);
const isRC = /(Release[_\s]?Candidate|\bRC\b)/i.test(line);
const isSelected = /(Selected)/i.test(line);
return { version, raw: line, isBeta, isRC, isSelected };
}).filter(Boolean);
core.info(`Installed Xcode versions:`);
installedXcodeEntries.forEach(e => core.info(` > ${e.version}${e.isBeta ? ' (Beta)' : e.isRC ? ' (RC)' : ''}`));
if (installedXcodeEntries.length === 0 || !xcodeVersionString.includes('latest')) {
if (installedXcodeEntries.length === 0 || !installedXcodeEntries.some(e => e.version === xcodeVersionString)) {
throw new Error(`Xcode version ${xcodeVersionString} is not installed! You will need to install this in a step before this one.`);
}
}
else {
const stableVersions = installedXcodeEntries.filter(e => !e.isBeta && !e.isRC);
if (stableVersions.length === 0) {
throw new Error('No stable (non-Beta / non-RC) Xcode versions installed!');
}
core.info(`Selecting latest installed Xcode version ${xcodeVersionString}...`);
xcodeVersionString = stableVersions[stableVersions.length - 1].version;
}
if (installedXcodeEntries.some(e => e.isSelected && e.version !== xcodeVersionString)) {
core.info(`Selecting new Xcode version ${xcodeVersionString}...`);
const selectExitCode = await (0, exec_1.exec)('xcodes', ['select', xcodeVersionString]);
if (selectExitCode !== 0) {
throw new Error(`Failed to select Xcode version ${xcodeVersionString}!`);
}
await (0, exec_1.exec)('xcodes', ['installed']);
}
await (0, exec_1.exec)('xcodes', ['installed']);
let xcodeVersionOutput = '';
xcodeVersionOutput = '';
await (0, exec_1.exec)('xcodebuild', ['-version'], {
listeners: {
stdout: (data) => {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-xcode-builder",
"version": "1.3.4",
"version": "1.4.0",
"description": "A GitHub Action to build, archive, and upload Unity exported xcode projects.",
"author": "buildalon",
"license": "MIT",
Expand All @@ -25,7 +25,7 @@
"uuid": "^10.0.0"
},
"devDependencies": {
"@types/node": "^22.18.1",
"@types/node": "^22.18.5",
"@types/plist": "^3.0.5",
"@types/semver": "^7.7.1",
"@types/uuid": "^10.0.0",
Expand Down
83 changes: 46 additions & 37 deletions src/xcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,58 +31,67 @@ const xcrun = '/usr/bin/xcrun';
const WORKSPACE = process.env.GITHUB_WORKSPACE || process.cwd();

export async function GetOrSetXcodeVersion(): Promise<SemVer> {
let xcodeVersionString = core.getInput('xcode-version');
let xcodeVersionString = core.getInput('xcode-version') || 'latest';

if (xcodeVersionString) {
core.info(`Setting xcode version to ${xcodeVersionString}`);
let xcodeVersionOutput = '';
core.info(`Setting xcode version to ${xcodeVersionString}`);
let xcodeVersionOutput = '';

const installedExitCode = await exec('xcodes', ['installed'], {
listeners: {
stdout: (data: Buffer) => {
xcodeVersionOutput += data.toString();
}
const installedExitCode = await exec('xcodes', ['installed'], {
listeners: {
stdout: (data: Buffer) => {
xcodeVersionOutput += data.toString();
}
});

if (installedExitCode !== 0) {
throw new Error('Failed to get installed Xcode versions!');
}
});

const installedXcodeVersions = xcodeVersionOutput.split('\n').map(line => {
const match = line.match(/(\d+\.\d+(\s\w+)?)/);
return match ? match[1] : null;
}).filter(Boolean) as string[];

core.info(`Installed Xcode versions:`);
installedXcodeVersions.forEach(version => core.info(` > ${version}`));

if (installedXcodeVersions.length === 0 || !xcodeVersionString.includes('latest')) {
if (installedXcodeVersions.length === 0 || !installedXcodeVersions.includes(xcodeVersionString)) {
throw new Error(`Xcode version ${xcodeVersionString} is not installed! You will need to install this is a step before this one.`);
}
} else {
// Exclude versions containing 'Beta' and select the latest version
const nonBetaVersions = installedXcodeVersions.filter(v => !/Beta/i.test(v));

if (nonBetaVersions.length === 0) {
throw new Error('No Xcode versions installed!');
}
if (installedExitCode !== 0) {
throw new Error('Failed to get installed Xcode versions!');
}

// Keep full lines so we can detect Beta & Release Candidate builds
const installedLines = xcodeVersionOutput.split('\n').filter(l => l.trim().length > 0);
type XcodeInstallEntry = { version: string; raw: string; isBeta: boolean; isRC: boolean; isSelected?: boolean; };
const installedXcodeEntries: XcodeInstallEntry[] = installedLines.map(line => {
const match = line.match(/^(\d+\.\d+)/); // first number like 16.4, 26.0
if (!match) { return null; }
const version = match[1];
const isBeta = /Beta/i.test(line);
// Detect various RC naming styles (Release Candidate, Release_Candidate, RC suffix/word)
const isRC = /(Release[_\s]?Candidate|\bRC\b)/i.test(line);
const isSelected = /(Selected)/i.test(line);
return { version, raw: line, isBeta, isRC, isSelected };
}).filter(Boolean) as XcodeInstallEntry[];

core.info(`Installed Xcode versions:`);
installedXcodeEntries.forEach(e => core.info(` > ${e.version}${e.isBeta ? ' (Beta)' : e.isRC ? ' (RC)' : ''}`));

if (installedXcodeEntries.length === 0 || !xcodeVersionString.includes('latest')) {
if (installedXcodeEntries.length === 0 || !installedXcodeEntries.some(e => e.version === xcodeVersionString)) {
throw new Error(`Xcode version ${xcodeVersionString} is not installed! You will need to install this in a step before this one.`);
}
} else {
// Exclude Beta & Release Candidate versions when selecting 'latest'
const stableVersions = installedXcodeEntries.filter(e => !e.isBeta && !e.isRC);

xcodeVersionString = nonBetaVersions[nonBetaVersions.length - 1];
if (stableVersions.length === 0) {
throw new Error('No stable (non-Beta / non-RC) Xcode versions installed!');
}

core.info(`Selecting latest installed Xcode version ${xcodeVersionString}...`);
xcodeVersionString = stableVersions[stableVersions.length - 1].version;
}

if (installedXcodeEntries.some(e => e.isSelected && e.version !== xcodeVersionString)) {
core.info(`Selecting new Xcode version ${xcodeVersionString}...`);
const selectExitCode = await exec('xcodes', ['select', xcodeVersionString]);

if (selectExitCode !== 0) {
throw new Error(`Failed to select Xcode version ${xcodeVersionString}!`);
}
}

await exec('xcodes', ['installed']);
await exec('xcodes', ['installed']);
}

let xcodeVersionOutput = '';
xcodeVersionOutput = '';
await exec('xcodebuild', ['-version'], {
listeners: {
stdout: (data: Buffer) => {
Expand Down
Loading