Skip to content

Commit 0b5051c

Browse files
unity-setup@1.0.19 (#23)
- fix improper version compare when checking current unity hub installation - fix linux self-hosted unity-hub upgrade
1 parent ea1ef9f commit 0b5051c

File tree

7 files changed

+59
-14
lines changed

7 files changed

+59
-14
lines changed

dist/index.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34371,13 +34371,30 @@ async function Get() {
3437134371
hubPath = await installUnityHub();
3437234372
}
3437334373
const hubVersion = await getInstalledHubVersion();
34374+
if (!semver.valid(hubVersion)) {
34375+
throw new Error(`Failed to get installed Unity Hub version ${hubVersion}!`);
34376+
}
3437434377
core.info(`Unity Hub Version:\n > ${hubVersion}`);
3437534378
const latestHubVersion = await getLatestHubVersion();
34376-
if (semver.lt(hubVersion, latestHubVersion)) {
34377-
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
34378-
await removePath(hubPath);
34379+
if (!semver.valid(latestHubVersion)) {
34380+
throw new Error(`Failed to get latest Unity Hub version ${latestHubVersion}!`);
34381+
}
34382+
core.debug(`Latest Unity Hub Version:\n > ${latestHubVersion}`);
34383+
core.debug(`Comparing versions:\n > ${hubVersion} < ${latestHubVersion} => ${semver.compare(hubVersion, latestHubVersion)}`);
34384+
if (semver.compare(hubVersion, latestHubVersion) < 0) {
3437934385
core.info(`Installing Latest Unity Hub Version:\n > ${latestHubVersion}`);
34380-
hubPath = await installUnityHub();
34386+
if (process.platform !== 'linux') {
34387+
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
34388+
await removePath(hubPath);
34389+
hubPath = await installUnityHub();
34390+
}
34391+
else {
34392+
const scriptPath = __nccwpck_require__.ab + "update-unityhub-linux.sh";
34393+
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "update-unityhub-linux.sh"]);
34394+
if (exitCode !== 0) {
34395+
throw new Error(`Failed to install Unity Hub: ${exitCode}`);
34396+
}
34397+
}
3438134398
}
3438234399
core.info(`Unity Hub Path:\n > "${hubPath}"`);
3438334400
core.exportVariable('UNITY_HUB_PATH', hubPath);
@@ -34790,7 +34807,7 @@ async function getChangeset(version) {
3479034807
async function removePath(targetPath) {
3479134808
core.startGroup(`deleting ${targetPath}...`);
3479234809
try {
34793-
await fs.promises.rm(targetPath, { recursive: true });
34810+
await fs.promises.rm(targetPath, { recursive: true, force: true });
3479434811
}
3479534812
finally {
3479634813
core.endGroup();

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/update-unityhub-linux.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | sudo tee /usr/share/keyrings/Unity_Technologies_ApS.gpg >/dev/null
4+
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'
5+
sudo apt-get update --allow-releaseinfo-change
6+
sudo apt-get install -y --no-install-recommends --only-upgrade unityhub

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "1.0.18",
3+
"version": "1.0.19",
44
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
55
"author": "Buildalon",
66
"license": "MIT",

src/unity-hub.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,29 @@ export async function Get(): Promise<string> {
4141
hubPath = await installUnityHub();
4242
}
4343
const hubVersion = await getInstalledHubVersion();
44+
if (!semver.valid(hubVersion)) {
45+
throw new Error(`Failed to get installed Unity Hub version ${hubVersion}!`);
46+
}
4447
core.info(`Unity Hub Version:\n > ${hubVersion}`);
4548
const latestHubVersion = await getLatestHubVersion();
46-
if (semver.lt(hubVersion, latestHubVersion)) {
47-
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
48-
await removePath(hubPath);
49+
if (!semver.valid(latestHubVersion)) {
50+
throw new Error(`Failed to get latest Unity Hub version ${latestHubVersion}!`);
51+
}
52+
core.debug(`Latest Unity Hub Version:\n > ${latestHubVersion}`);
53+
core.debug(`Comparing versions:\n > ${hubVersion} < ${latestHubVersion} => ${semver.compare(hubVersion, latestHubVersion)}`);
54+
if (semver.compare(hubVersion, latestHubVersion) < 0) {
4955
core.info(`Installing Latest Unity Hub Version:\n > ${latestHubVersion}`);
50-
hubPath = await installUnityHub();
56+
if (process.platform !== 'linux') {
57+
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
58+
await removePath(hubPath);
59+
hubPath = await installUnityHub();
60+
} else {
61+
const scriptPath = path.join(__dirname, 'update-unityhub-linux.sh');
62+
const exitCode = await exec.exec('sh', [scriptPath]);
63+
if (exitCode !== 0) {
64+
throw new Error(`Failed to install Unity Hub: ${exitCode}`);
65+
}
66+
}
5167
}
5268
core.info(`Unity Hub Path:\n > "${hubPath}"`);
5369
core.exportVariable('UNITY_HUB_PATH', hubPath);
@@ -466,7 +482,7 @@ async function getChangeset(version: string): Promise<string | null> {
466482
async function removePath(targetPath: string): Promise<void> {
467483
core.startGroup(`deleting ${targetPath}...`);
468484
try {
469-
await fs.promises.rm(targetPath, { recursive: true });
485+
await fs.promises.rm(targetPath, { recursive: true, force: true });
470486
} finally {
471487
core.endGroup();
472488
}

src/update-unityhub-linux.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | sudo tee /usr/share/keyrings/Unity_Technologies_ApS.gpg >/dev/null
4+
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'
5+
sudo apt-get update --allow-releaseinfo-change
6+
sudo apt-get install -y --no-install-recommends --only-upgrade unityhub

0 commit comments

Comments
 (0)