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

Commit 8a66fa7

Browse files
- misc cleanup - better macos installation support
1 parent 75bee72 commit 8a66fa7

File tree

7 files changed

+105
-75
lines changed

7 files changed

+105
-75
lines changed

.github/workflows/validate.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
- os: ubuntu-latest
2929
build-targets: 'StandaloneLinux64 Android iOS'
3030
- os: windows-latest
31-
build-targets: 'StandaloneWindows64 Android iOS'
32-
- os: macos-14
33-
build-targets: 'StandaloneOSX Android iOS VisionOS'
31+
build-targets: 'StandaloneWindows64 Android WSAPlayer'
32+
- os: macos-13
33+
build-targets: 'StandaloneOSX iOS'
3434
- os: macos-latest
35-
build-targets: 'StandaloneOSX Android iOS'
35+
build-targets: 'StandaloneOSX iOS VisionOS'
3636

3737
steps:
3838
- name: checkout self

dist/index.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -28088,8 +28088,8 @@ const main = async () => {
2808828088
core.debug(`buildTargets: ${buildTargets}`);
2808928089

2809028090
if (!buildTargets) {
28091-
modules = core.getInput('modules');
28092-
var modules = modules.replace(/,/g, '').split(/\s+/);
28091+
modules = core.getInput('modules');
28092+
var modules = modules.replace(/,/g, '').split(/\s+/);
2809328093
} else {
2809428094
const osType = os.type();
2809528095
var moduleMap = undefined;
@@ -28169,15 +28169,9 @@ const main = async () => {
2816928169

2817028170
var pwsh = await io.which("pwsh", true);
2817128171
var install = __nccwpck_require__.ab + "unity-install.ps1";
28172-
var exitCode = 0;
28173-
28174-
exitCode = await exec.exec(`"${pwsh}" -Command`, `${install} ${args}`);
28175-
28176-
if (exitCode != 0) {
28177-
throw Error(`Unity Installation Failed! exitCode: ${exitCode}`)
28178-
}
28172+
await exec.exec(`"${pwsh}" -Command`, `${install} ${args}`);
2817928173
} catch (error) {
28180-
core.setFailed(error.message);
28174+
core.setFailed(`Unity Installation Failed! ${error.message}`);
2818128175
}
2818228176
}
2818328177

@@ -28199,7 +28193,7 @@ const findFile = async (dir, filePath) => {
2819928193
}
2820028194

2820128195
if (matchedFiles.length == 0) {
28202-
for(const subDir of directories) {
28196+
for (const subDir of directories) {
2820328197
const nestedMatches = await findFile(subDir, filePath);
2820428198

2820528199
for (const nestedMatch of nestedMatches) {

dist/unity-install.ps1

+44-23
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if ([String]::IsNullOrEmpty($unityVersion)) {
1717
}
1818

1919
$projectPath = (Get-Item $versionFilePath).Directory.Parent.FullName
20-
$projectPath = $projectPath -replace '\\','/'
20+
$projectPath = $projectPath -replace '\\', '/'
2121
Write-Host "Unity project path: `"$projectPath`""
2222
"UNITY_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV
2323
}
@@ -27,7 +27,8 @@ if ([String]::IsNullOrEmpty($unityVersion)) {
2727
$vMatches = [regex]::Matches($version, $pattern)
2828
$unityVersion = $vMatches[1].Groups['version'].Value.Trim()
2929
$unityVersionChangeSet = $vMatches[2].Groups['revision'].Value.Trim()
30-
} else {
30+
}
31+
else {
3132
$version = $unityVersion
3233
$unityVersionChangeSet = $version -replace '.*\((.*)\)', '$1'
3334
$unityVersion = $version -replace '\s*\(.*\)', ''
@@ -37,7 +38,8 @@ if (-not ([String]::IsNullOrEmpty($unityVersion))) {
3738
Write-Host ""
3839
"UNITY_EDITOR_VERSION=$unityVersion" >> $env:GITHUB_ENV
3940
Write-Host "Unity Editor version set to: $unityVersion"
40-
} else {
41+
}
42+
else {
4143
Write-Error "Failed to determine editor version to install!"
4244
exit 1
4345
}
@@ -53,11 +55,12 @@ if ($IsWindows) {
5355

5456
#. 'C:/Program Files/Unity Hub/Unity Hub.exe' -- --headless help
5557
function Invoke-UnityHub {
56-
$argList = (@('--','--headless') + $args.Split(" "))
58+
$argList = (@('--', '--headless') + $args.Split(" "))
5759
$p = Start-Process -NoNewWindow -PassThru -Wait -FilePath "$hubPath" -ArgumentList $argList
5860
$p.WaitForExit()
5961
}
60-
} elseif ($IsMacOS) {
62+
}
63+
elseif ($IsMacOS) {
6164
$hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
6265
$editorRootPath = "/Applications/Unity/Hub/Editor/"
6366
$editorFileEx = "/Unity.app/Contents/MacOS/Unity"
@@ -68,11 +71,12 @@ if ($IsWindows) {
6871

6972
#. "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" -- --headless help
7073
function Invoke-UnityHub {
71-
$argList = (@('--','--headless') + $args.Split(" "))
74+
$argList = (@('--', '--headless') + $args.Split(" "))
7275
$p = Start-Process -NoNewWindow -PassThru -Wait -FilePath "$hubPath" -ArgumentList $argList
7376
$p.WaitForExit()
7477
}
75-
} elseif ($IsLinux) {
78+
}
79+
elseif ($IsLinux) {
7680
$hubPath = "/usr/bin/unityhub"
7781
$editorRootPath = "$HOME/Unity/Hub/Editor/"
7882
$editorFileEx = "/Editor/Unity"
@@ -86,7 +90,8 @@ if ($IsWindows) {
8690
$argsList = $args.Split(" ")
8791
xvfb-run --auto-servernum "$hubPath" --disable-gpu-sandbox --headless $argsList
8892
}
89-
} else {
93+
}
94+
else {
9095
Write-Error "Unsupported platform: $($global:PSVersionTable.Platform)"
9196
exit 1
9297
}
@@ -115,7 +120,8 @@ if ( -not (Test-Path -Path "$hubPath") ) {
115120
Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)"
116121
exit 1
117122
}
118-
} elseif ($IsMacOS) {
123+
}
124+
elseif ($IsMacOS) {
119125
Write-Host "::group::Installing Unity Hub on macOS..."
120126
$package = "UnityHubSetup.dmg"
121127
$downloadPath = "$outPath/$package"
@@ -146,17 +152,28 @@ if ( -not (Test-Path -Path "$hubPath") ) {
146152

147153
sudo cp -rf $dmgAppPath "/Applications"
148154
hdiutil unmount $dmgVolume
155+
156+
if (!(Test-Path $hubPath)) {
157+
Write-Error "Failed to install Unity Hub"
158+
exit 1
159+
}
160+
161+
Write-Host "Unity Hub installed at `"$hubPath`""
162+
163+
sudo chmod -R 777 $hubPath
149164
sudo mkdir -p "/Library/Application Support/Unity"
150-
sudo chmod 775 "/Library/Application Support/Unity"
151-
touch '/Library/Application Support/Unity/temp'
152-
} elseif ($IsLinux) {
165+
sudo chmod -R 777 "/Library/Application Support/Unity"
166+
}
167+
elseif ($IsLinux) {
153168
Write-Host "::group::Installing Unity Hub on ubuntu..."
154169
sudo sh -c 'echo ""deb https://hub.unity3d.com/linux/repos/deb stable main"" > /etc/apt/sources.list.d/unityhub.list'
155170
wget -qO - https://hub.unity3d.com/linux/keys/public | sudo apt-key add -
156171
sudo apt update
157172
sudo apt install -y unityhub
158173
$hubPath = which unityhub
159-
} else {
174+
sudo chmod -R 777 $hubPath
175+
}
176+
else {
160177
Write-Error "Unsupported platform: $($global:PSVersionTable.Platform)"
161178
exit 1
162179
}
@@ -181,7 +198,7 @@ Write-Host "::endgroup::"
181198
#}
182199

183200
# set the editor path
184-
$editorPath = "{0}{1}{2}" -f $editorRootPath,$unityVersion,$editorFileEx
201+
$editorPath = "{0}{1}{2}" -f $editorRootPath, $unityVersion, $editorFileEx
185202

186203
# if architecture is set, check if the specific architecture is installed
187204
if (-not [string]::IsNullOrEmpty($architecture)) {
@@ -192,12 +209,15 @@ if (-not [string]::IsNullOrEmpty($architecture)) {
192209

193210
# iterate over the editors and check if the version name contains (Intel) for x86_64 or (Apple silicon) for arm64
194211
foreach ($archEditor in $archEditors) {
212+
Write-Host "::debug::$archEditor"
213+
195214
if ($IsMacOS) {
196215
if ((($archEditor.Contains("(Intel)") -and $architecture -eq 'x86_64')) -or ($archEditor.Contains("(Apple silicon)") -and $architecture -eq 'arm64')) {
197216
# set the editor path based on the editor string that was found using a substring. Split subtring by ',' and take the last element
198217
$editorPath = $archEditor.Substring(0, $archEditor.IndexOf(','))
199218
}
200-
} else {
219+
}
220+
else {
201221
Write-Error "Architecture lookup not supported for $($global:PSVersionTable.Platform)"
202222
exit 1
203223
}
@@ -242,17 +262,18 @@ function AddModules {
242262

243263
if (-not (Test-Path -Path $editorPath)) {
244264
Write-Host "Installing $unityVersion ($unityVersionChangeSet)"
245-
$installArgs = @('install',"--version $unityVersion","--changeset $unityVersionChangeSet",'--cm')
265+
$installArgs = @('install', "--version $unityVersion", "--changeset $unityVersionChangeSet", '--cm')
246266
$installModules = AddModules
247267

248268
if (-not [string]::IsNullOrEmpty($architecture)) {
249269
$installArgs += "-a $architecture"
250270
}
251271

252272
Invoke-Hub-Install $installModules $installArgs
253-
} else {
273+
}
274+
else {
254275
Write-Host "Checking modules for $unityVersion ($unityVersionChangeSet)"
255-
$installArgs = @('install-modules',"--version $unityVersion",'--cm')
276+
$installArgs = @('install-modules', "--version $unityVersion", '--cm')
256277
$installModules = AddModules
257278

258279
if ($installModules.Count -gt 0) {
@@ -264,14 +285,14 @@ Write-Host "Installed Editors:"
264285
Invoke-UnityHub editors -i
265286

266287
if (-not (Test-Path -Path $editorPath)) {
267-
Write-Error "Failed to validate installed editor path at $editorPath"
288+
Write-Error "Failed to validate installed editor path at `"$editorPath`""
268289
exit 1
269290
}
270291

271-
$modulesPath = '{0}{1}/modules.json' -f $editorRootPath,$UnityVersion
292+
$modulesPath = '{0}{1}/modules.json' -f $editorRootPath, $UnityVersion
272293

273294
if (-not (Test-Path -Path $modulesPath)) {
274-
$editorPath = "{0}{1}" -f $editorRootPath,$unityVersion
295+
$editorPath = "{0}{1}" -f $editorRootPath, $unityVersion
275296
Write-Error "Failed to resolve modules path at $modulesPath"
276297

277298
if (Test-Path -Path $editorPath) {
@@ -295,9 +316,9 @@ $envEditorPath = $env:UNITY_EDITOR_PATH
295316

296317
if ([String]::IsNullOrEmpty($envEditorPath)) {
297318
Write-Host ""
298-
$editorPath = $editorPath -replace '\\','/'
319+
$editorPath = $editorPath -replace '\\', '/'
299320
"UNITY_EDITOR_PATH=$editorPath" >> $env:GITHUB_ENV
300-
Write-Host "UnityEditor path set to: $editorPath"
321+
Write-Host "UnityEditor path set to: `"$editorPath`""
301322
}
302323

303324
exit 0

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "7.5.2",
3+
"version": "7.5.3",
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

+5-11
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const main = async () => {
2727
core.debug(`buildTargets: ${buildTargets}`);
2828

2929
if (!buildTargets) {
30-
modules = core.getInput('modules');
31-
var modules = modules.replace(/,/g, '').split(/\s+/);
30+
modules = core.getInput('modules');
31+
var modules = modules.replace(/,/g, '').split(/\s+/);
3232
} else {
3333
const osType = os.type();
3434
var moduleMap = undefined;
@@ -108,15 +108,9 @@ const main = async () => {
108108

109109
var pwsh = await io.which("pwsh", true);
110110
var install = path.resolve(__dirname, 'unity-install.ps1');
111-
var exitCode = 0;
112-
113-
exitCode = await exec.exec(`"${pwsh}" -Command`, `${install} ${args}`);
114-
115-
if (exitCode != 0) {
116-
throw Error(`Unity Installation Failed! exitCode: ${exitCode}`)
117-
}
111+
await exec.exec(`"${pwsh}" -Command`, `${install} ${args}`);
118112
} catch (error) {
119-
core.setFailed(error.message);
113+
core.setFailed(`Unity Installation Failed! ${error.message}`);
120114
}
121115
}
122116

@@ -138,7 +132,7 @@ const findFile = async (dir, filePath) => {
138132
}
139133

140134
if (matchedFiles.length == 0) {
141-
for(const subDir of directories) {
135+
for (const subDir of directories) {
142136
const nestedMatches = await findFile(subDir, filePath);
143137

144138
for (const nestedMatch of nestedMatches) {

0 commit comments

Comments
 (0)