Skip to content

Commit 404cae1

Browse files
unity-setup@v1.0.17 (#21)
- remove previous unity hub before attempting to install new version - install correct unity hub based on cpu arch
1 parent 7791766 commit 404cae1

File tree

9 files changed

+1858
-1943
lines changed

9 files changed

+1858
-1943
lines changed

dist/index.js

Lines changed: 1719 additions & 1835 deletions
Large diffs are not rendered by default.

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.

dist/install-unityhub-macos.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
set -e
33
echo "::group::Installing Unity Hub..."
44
baseUrl="https://public-cdn.cloud.unity3d.com/hub/prod"
5-
url="$baseUrl/UnityHubSetup.dmg"
6-
downloadPath="$RUNNER_TEMP/UnityHubSetup.dmg"
5+
cpuArch=$(uname -m)
6+
if [ "$cpuArch" == "arm64" ]; then
7+
cpuArch="arm64"
8+
else
9+
cpuArch="x64"
10+
fi
11+
fileName="UnityHubSetup"
12+
url="$baseUrl/$fileName-$cpuArch.dmg"
13+
downloadPath="$RUNNER_TEMP/$fileName-$cpuArch.dmg"
714
echo "Downloading Unity Hub from $url to $downloadPath..."
815
wget -qO "$downloadPath" "$url"
916
if [ ! -f "$downloadPath" ]; then

dist/licenses.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
442442
SOFTWARE.
443443

444444

445-
uuid
446-
MIT
447-
The MIT License (MIT)
448-
449-
Copyright (c) 2010-2020 Robert Kieffer and other contributors
450-
451-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
452-
453-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
454-
455-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
456-
457-
458445
wrappy
459446
ISC
460447
The ISC License

package-lock.json

Lines changed: 98 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "1.0.16",
3+
"version": "1.0.17",
44
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
55
"author": "Buildalon",
66
"license": "MIT",
@@ -24,19 +24,19 @@
2424
"action"
2525
],
2626
"dependencies": {
27-
"@actions/core": "^1.10.1",
27+
"@actions/core": "^1.11.1",
2828
"@actions/exec": "^1.1.1",
2929
"@actions/glob": "^0.4.0",
30-
"@electron/asar": "^3.2.10",
31-
"semver": "^7.6.3",
32-
"yaml": "^2.5.0"
30+
"@electron/asar": "^3.4.1",
31+
"semver": "^7.7.1",
32+
"yaml": "^2.7.1"
3333
},
3434
"devDependencies": {
35-
"@types/node": "^22.2.0",
36-
"@types/semver": "^7.5.8",
35+
"@types/node": "^22.15.3",
36+
"@types/semver": "^7.7.0",
3737
"@vercel/ncc": "^0.34.0",
3838
"shx": "^0.3.4",
39-
"typescript": "^5.5.4"
39+
"typescript": "^5.8.3"
4040
},
4141
"scripts": {
4242
"build": "npm run clean && npm run bundle",

src/install-unityhub-macos.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
set -e
33
echo "::group::Installing Unity Hub..."
44
baseUrl="https://public-cdn.cloud.unity3d.com/hub/prod"
5-
url="$baseUrl/UnityHubSetup.dmg"
6-
downloadPath="$RUNNER_TEMP/UnityHubSetup.dmg"
5+
cpuArch=$(uname -m)
6+
if [ "$cpuArch" == "arm64" ]; then
7+
cpuArch="arm64"
8+
else
9+
cpuArch="x64"
10+
fi
11+
fileName="UnityHubSetup"
12+
url="$baseUrl/$fileName-$cpuArch.dmg"
13+
downloadPath="$RUNNER_TEMP/$fileName-$cpuArch.dmg"
714
echo "Downloading Unity Hub from $url to $downloadPath..."
815
wget -qO "$downloadPath" "$url"
916
if [ ! -f "$downloadPath" ]; then

src/unity-hub.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function init(): { hubPath: string, editorRootPath: string, editorFileExtension:
3434
}
3535
}
3636

37-
async function Get(): Promise<string> {
37+
export async function Get(): Promise<string> {
3838
try {
3939
await fs.promises.access(hubPath, fs.constants.X_OK);
4040
} catch (error) {
@@ -44,6 +44,8 @@ async function Get(): Promise<string> {
4444
core.info(`Unity Hub Version:\n > ${hubVersion}`);
4545
const latestHubVersion = await getLatestHubVersion();
4646
if (semver.lt(hubVersion, latestHubVersion)) {
47+
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
48+
await removePath(hubPath);
4749
core.info(`Installing Latest Unity Hub Version:\n > ${latestHubVersion}`);
4850
hubPath = await installUnityHub();
4951
}
@@ -222,7 +224,7 @@ async function execUnityHub(args: string[]): Promise<string> {
222224
return output;
223225
}
224226

225-
async function Unity(version: string, changeset: string, architecture: string, modules: string[]): Promise<string> {
227+
export async function Unity(version: string, changeset: string, architecture: string, modules: string[]): Promise<string> {
226228
if (os.arch() == 'arm64' && !isArmCompatible(version)) {
227229
core.info(`Unity ${version} does not support arm64 architecture, falling back to x86_64`);
228230
architecture = 'x86_64';
@@ -238,7 +240,7 @@ async function Unity(version: string, changeset: string, architecture: string, m
238240
await installUnity(version, changeset, architecture, modules);
239241
} catch (error) {
240242
if (error.message.includes('Editor already installed in this location')) {
241-
uninstallUnity(editorPath);
243+
removePath(editorPath);
242244
await installUnity(version, changeset, architecture, modules);
243245
}
244246
}
@@ -264,7 +266,7 @@ async function Unity(version: string, changeset: string, architecture: string, m
264266
}
265267
} catch (error) {
266268
if (error.message.includes(`No modules found`)) {
267-
uninstallUnity(editorPath);
269+
removePath(editorPath);
268270
await Unity(version, changeset, architecture, modules);
269271
}
270272
} finally {
@@ -346,7 +348,7 @@ async function installUnity(version: string, changeset: string, architecture: st
346348
}
347349
}
348350

349-
async function ListInstalledEditors(): Promise<string> {
351+
export async function ListInstalledEditors(): Promise<string> {
350352
return await execUnityHub(['editors', '-i']);
351353
}
352354

@@ -442,13 +444,11 @@ async function getModulesContent(modulesPath: string): Promise<any> {
442444
return JSON.parse(modulesContent);
443445
}
444446

445-
async function uninstallUnity(editorPath: string): Promise<void> {
446-
core.startGroup(`Uninstalling ${editorPath}...`);
447+
async function removePath(targetPath: string): Promise<void> {
448+
core.startGroup(`deleting ${targetPath}...`);
447449
try {
448-
await fs.promises.rm(editorPath, { recursive: true });
450+
await fs.promises.rm(targetPath, { recursive: true });
449451
} finally {
450452
core.endGroup();
451453
}
452454
}
453-
454-
export { Get, Unity, ListInstalledEditors }

src/utility.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import glob = require('@actions/glob');
33
import path = require('path');
44
import fs = require('fs');
55

6-
async function GetHubRootPath(hubPath: string): Promise<string> {
6+
export async function GetHubRootPath(hubPath: string): Promise<string> {
77
core.debug(`searching for hub root path: ${hubPath}`);
88
let hubRootPath = hubPath;
99
switch (process.platform) {
@@ -20,7 +20,7 @@ async function GetHubRootPath(hubPath: string): Promise<string> {
2020
return hubRootPath;
2121
}
2222

23-
async function GetEditorRootPath(editorPath: string): Promise<string> {
23+
export async function GetEditorRootPath(editorPath: string): Promise<string> {
2424
core.debug(`searching for editor root path: ${editorPath}`);
2525
let editorRootPath = editorPath;
2626
switch (process.platform) {
@@ -39,7 +39,7 @@ async function GetEditorRootPath(editorPath: string): Promise<string> {
3939
return editorRootPath;
4040
}
4141

42-
async function ReadFileContents(filePath: string): Promise<string> {
42+
export async function ReadFileContents(filePath: string): Promise<string> {
4343
const fileHandle = await fs.promises.open(filePath, 'r');
4444
try {
4545
const projectSettingsContent = await fileHandle.readFile('utf8');
@@ -49,13 +49,11 @@ async function ReadFileContents(filePath: string): Promise<string> {
4949
}
5050
}
5151

52-
async function FindGlobPattern(pattern: string): Promise<string | undefined> {
52+
export async function FindGlobPattern(pattern: string): Promise<string | undefined> {
5353
core.debug(`searching for: ${pattern}...`);
5454
const globber = await glob.create(pattern);
5555
for await (const file of globber.globGenerator()) {
5656
core.debug(`found glob: ${file}`);
5757
return file;
5858
}
5959
}
60-
61-
export { GetHubRootPath, GetEditorRootPath, ReadFileContents, FindGlobPattern }

0 commit comments

Comments
 (0)