Skip to content
This repository was archived by the owner on Aug 11, 2024. It is now read-only.

Commit d981b42

Browse files
* fix macos silicon arch * update docs and run build * update how we set arch * clean it up a bit * fix typo * log stdout * try another way * use info * try yet another way * try non async * try another completely different way * make sure we resolve correctly * log errors * revert * some cleanup * use arch * add i386 case * this was right * try with mac-xl * try different label * try a different label * try mac 13 beta * use arm64 * switch back to the latest * try with arm tag again * I guess try 14 * revert * switch to debug
1 parent ad8cf87 commit d981b42

File tree

7 files changed

+89
-9
lines changed

7 files changed

+89
-9
lines changed

.github/workflows/validate.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ jobs:
3333

3434
steps:
3535
- name: checkout self
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737

3838
- run: npm install
3939

4040
- name: checkout test project
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242
with:
4343
repository: xrtk/com.xrtk.test
4444
path: test-project

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ jobs:
3737
build-targets: 'StandaloneOSX Android iOS'
3838

3939
steps:
40-
- uses: actions/checkout@v3
40+
- uses: actions/checkout@v4
4141

4242
- id: unity-setup
43-
uses: xrtk/unity-setup@v7.2
43+
uses: xrtk/unity-setup@v7.3
4444
with:
4545
build-targets: ${{ matrix.build-targets }} #Optional, overrides the default platform specific module installs.
4646
#version-file-path: 'ProjectSettings/ProjectVersion.txt' # Optional

dist/index.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -4127,6 +4127,7 @@ const os = __nccwpck_require__(37);
41274127
const main = async () => {
41284128
try {
41294129
var modules = '';
4130+
var architecture = '';
41304131
var buildTargets = core.getInput('build-targets');
41314132
core.debug(`buildTargets: ${buildTargets}`);
41324133

@@ -4153,6 +4154,9 @@ const main = async () => {
41534154
"StandaloneLinux64": "linux-il2cpp",
41544155
"WebGL": "webgl",
41554156
};
4157+
4158+
architecture = await getArchitecture();
4159+
core.debug(`architecture: ${architecture}`);
41564160
} else if (osType == 'Windows_NT') {
41574161
moduleMap = {
41584162
"StandaloneWindows64": "windows-il2cpp",
@@ -4201,7 +4205,7 @@ const main = async () => {
42014205
core.debug(`modules: ${modules}`);
42024206
core.debug(`versionFilePath: ${versionFilePath}`);
42034207

4204-
var args = `-modulesList \"${modules}\" -versionFilePath \"${versionFilePath}\"`;
4208+
var args = `-modulesList \"${modules}\" -versionFilePath \"${versionFilePath}\" -architecture \"${architecture}\"`;
42054209
var pwsh = await io.which("pwsh", true);
42064210
var install = __nccwpck_require__.ab + "unity-install.ps1";
42074211
var exitCode = 0;
@@ -4247,6 +4251,32 @@ const findFile = async (dir, filePath) => {
42474251
return matchedFiles;
42484252
};
42494253

4254+
const getArchitecture = () => {
4255+
return new Promise((resolve, reject) => {
4256+
try {
4257+
const options = {
4258+
listeners: {
4259+
stdout: (data) => {
4260+
const trimmedOutput = data.toString().trim();
4261+
core.debug(`getArchitecture::stdout: ${trimmedOutput}`);
4262+
4263+
if (trimmedOutput.toLowerCase().includes('x86_64')) {
4264+
resolve('x86_64');
4265+
} else if (trimmedOutput.toLowerCase().includes('arm64')) {
4266+
resolve('arm64');
4267+
} else {
4268+
reject(Error(`Unknown architecture: Unable to determine architecture: ${trimmedOutput}`));
4269+
}
4270+
},
4271+
},
4272+
};
4273+
4274+
exec.exec('uname -m', [], options);
4275+
} catch (error) {
4276+
reject(Error(`Failed to determine architecture: ${error.message}`));
4277+
}
4278+
});
4279+
};
42504280

42514281
// Call the main function to run the action
42524282
main();

dist/unity-install.ps1

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
param(
22
[String]$versionFilePath,
3-
[String]$modulesList
3+
[String]$modulesList,
4+
[String]$architecture
45
)
56
# Unity Editor Installation
67
$modules = $modulesList.Split(" ")
@@ -145,12 +146,21 @@ Write-Host "::group::Unity Hub Options"
145146
Invoke-UnityHub help
146147
Write-Host "::endgroup::"
147148

149+
# only show errors if github actions debug is enabled
150+
#if ($env:GITHUB_ACTIONS -eq "true") {
151+
Invoke-UnityHub --errors
152+
#}
153+
148154
$editorPath = "{0}{1}{2}" -f $editorRootPath,$unityVersion,$editorFileEx
149155

150156
if ( -not (Test-Path -Path $editorPath)) {
151157
Write-Host "Installing $unityVersion ($unityVersionChangeSet)"
152158
$installArgs = @('install',"--version $unityVersion","--changeset $unityVersionChangeSet",'--cm')
153159

160+
if (-not [string]::IsNullOrEmpty($architecture)) {
161+
$installArgs += "-a $architecture"
162+
}
163+
154164
$addModules = @()
155165

156166
foreach ($module in $modules) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "7.2.0",
3+
"version": "7.3.0",
44
"description": "An atomic GitHub action to download and install the Unity Editor for runners.",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const os = require('os');
99
const main = async () => {
1010
try {
1111
var modules = '';
12+
var architecture = '';
1213
var buildTargets = core.getInput('build-targets');
1314
core.debug(`buildTargets: ${buildTargets}`);
1415

@@ -35,6 +36,9 @@ const main = async () => {
3536
"StandaloneLinux64": "linux-il2cpp",
3637
"WebGL": "webgl",
3738
};
39+
40+
architecture = await getArchitecture();
41+
core.debug(`architecture: ${architecture}`);
3842
} else if (osType == 'Windows_NT') {
3943
moduleMap = {
4044
"StandaloneWindows64": "windows-il2cpp",
@@ -83,7 +87,7 @@ const main = async () => {
8387
core.debug(`modules: ${modules}`);
8488
core.debug(`versionFilePath: ${versionFilePath}`);
8589

86-
var args = `-modulesList \"${modules}\" -versionFilePath \"${versionFilePath}\"`;
90+
var args = `-modulesList \"${modules}\" -versionFilePath \"${versionFilePath}\" -architecture \"${architecture}\"`;
8791
var pwsh = await io.which("pwsh", true);
8892
var install = path.resolve(__dirname, 'unity-install.ps1');
8993
var exitCode = 0;
@@ -129,6 +133,32 @@ const findFile = async (dir, filePath) => {
129133
return matchedFiles;
130134
};
131135

136+
const getArchitecture = () => {
137+
return new Promise((resolve, reject) => {
138+
try {
139+
const options = {
140+
listeners: {
141+
stdout: (data) => {
142+
const trimmedOutput = data.toString().trim();
143+
core.debug(`getArchitecture::stdout: ${trimmedOutput}`);
144+
145+
if (trimmedOutput.toLowerCase().includes('x86_64')) {
146+
resolve('x86_64');
147+
} else if (trimmedOutput.toLowerCase().includes('arm64')) {
148+
resolve('arm64');
149+
} else {
150+
reject(Error(`Unknown architecture: Unable to determine architecture: ${trimmedOutput}`));
151+
}
152+
},
153+
},
154+
};
155+
156+
exec.exec('uname -m', [], options);
157+
} catch (error) {
158+
reject(Error(`Failed to determine architecture: ${error.message}`));
159+
}
160+
});
161+
};
132162

133163
// Call the main function to run the action
134164
main();

src/unity-install.ps1

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
param(
22
[String]$versionFilePath,
3-
[String]$modulesList
3+
[String]$modulesList,
4+
[String]$architecture
45
)
56
# Unity Editor Installation
67
$modules = $modulesList.Split(" ")
@@ -145,12 +146,21 @@ Write-Host "::group::Unity Hub Options"
145146
Invoke-UnityHub help
146147
Write-Host "::endgroup::"
147148

149+
# only show errors if github actions debug is enabled
150+
#if ($env:GITHUB_ACTIONS -eq "true") {
151+
Invoke-UnityHub --errors
152+
#}
153+
148154
$editorPath = "{0}{1}{2}" -f $editorRootPath,$unityVersion,$editorFileEx
149155

150156
if ( -not (Test-Path -Path $editorPath)) {
151157
Write-Host "Installing $unityVersion ($unityVersionChangeSet)"
152158
$installArgs = @('install',"--version $unityVersion","--changeset $unityVersionChangeSet",'--cm')
153159

160+
if (-not [string]::IsNullOrEmpty($architecture)) {
161+
$installArgs += "-a $architecture"
162+
}
163+
154164
$addModules = @()
155165

156166
foreach ($module in $modules) {

0 commit comments

Comments
 (0)