Skip to content

Commit 8371eb5

Browse files
unity-setup@v1.2.6 (#42)
- Removed the automatic version check for Unity Hub when it's already installed - Fixed the legacy URL check fallback mechanism for fetching Unity version information - Added version-specific Linux dependency installation for older Unity Editor versions
1 parent 58c2adc commit 8371eb5

14 files changed

+442
-169
lines changed

.github/workflows/build-options.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"2021.3.x",
1313
"2022.x",
1414
"6000.0.x",
15+
"6000.1.x",
1516
"6000"
1617
],
1718
"include": [
@@ -30,30 +31,78 @@
3031
"build-targets": "StandaloneOSX Android iOS VisionOS",
3132
"modules": "mac-server"
3233
},
34+
{
35+
"os": "ubuntu-latest",
36+
"build-targets": "None",
37+
"modules": "None"
38+
},
39+
{
40+
"os": "windows-latest",
41+
"build-targets": "None",
42+
"modules": "None"
43+
},
44+
{
45+
"os": "macos-latest",
46+
"build-targets": "None",
47+
"modules": "None"
48+
},
3349
{
3450
"os": "ubuntu-latest",
3551
"unity-version": "2019.4.40f1",
52+
"build-targets": "None",
3653
"modules": "None"
3754
},
3855
{
3956
"os": "ubuntu-latest",
4057
"unity-version": "2018.4.36f1 (6cd387d23174)",
58+
"build-targets": "None",
4159
"modules": "None"
4260
},
4361
{
4462
"os": "ubuntu-latest",
4563
"unity-version": "2017.4.40f1 (6e14067f8a9a)",
64+
"build-targets": "None",
4665
"modules": "None"
4766
}
4867
],
4968
"exclude": [
69+
{
70+
"os": "ubuntu-latest",
71+
"unity-version": "None",
72+
"build-targets": "StandaloneLinux64, Android, iOS",
73+
"modules": "linux-server"
74+
},
75+
{
76+
"os": "windows-latest",
77+
"unity-version": "None",
78+
"build-targets": "StandaloneWindows64, Android, WSAPlayer",
79+
"modules": "windows-server"
80+
},
81+
{
82+
"os": "macos-latest",
83+
"unity-version": "None",
84+
"build-targets": "StandaloneOSX Android iOS VisionOS",
85+
"modules": "mac-server"
86+
},
5087
{
5188
"os": "ubuntu-latest",
5289
"unity-version": "5.6.7f1 (e80cc3114ac1)"
5390
},
5491
{
5592
"os": "ubuntu-latest",
5693
"unity-version": "4.7.2"
94+
},
95+
{
96+
"os": "windows-latest",
97+
"unity-version": "4.7.2",
98+
"build-targets": "StandaloneWindows64, Android, WSAPlayer",
99+
"modules": "windows-server"
100+
},
101+
{
102+
"os": "macos-latest",
103+
"unity-version": "4.7.2",
104+
"build-targets": "StandaloneOSX Android iOS VisionOS",
105+
"modules": "mac-server"
57106
}
58107
]
59108
}

.github/workflows/validate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
id: setup-jobs
2525
with:
2626
build-options: ./.github/workflows/build-options.json
27-
group-by: 'os'
27+
group-by: 'unity-version'
2828
outputs:
2929
jobs: ${{ steps.setup-jobs.outputs.jobs }}
3030
validate:
@@ -35,6 +35,8 @@ jobs:
3535
contents: read
3636
strategy:
3737
matrix: ${{ fromJSON(needs.setup.outputs.jobs) }}
38+
fail-fast: false
39+
max-parallel: 1
3840
secrets: inherit
3941
uses: ./.github/workflows/build.yml
4042
with:

dist/index.js

Lines changed: 99 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -35503,19 +35503,27 @@ async function ValidateInputs() {
3550335503
core.info(` > ${module}`);
3550435504
}
3550535505
}
35506+
if (modules.length === 0) {
35507+
core.info(` > None`);
35508+
}
3550635509
core.info(`buildTargets:`);
3550735510
const moduleMap = getPlatformTargetModuleMap();
3550835511
for (const target of buildTargets) {
3550935512
const module = moduleMap[target];
3551035513
if (module === undefined) {
35511-
core.warning(`${target} not a valid build target!`);
35514+
if (target.toLowerCase() !== 'none') {
35515+
core.warning(`${target} is not a valid build target for ${os.type()}`);
35516+
}
3551235517
continue;
3551335518
}
3551435519
if (!modules.includes(module)) {
3551535520
modules.push(module);
3551635521
core.info(` > ${target} -> ${module}`);
3551735522
}
3551835523
}
35524+
if (buildTargets.length == 0) {
35525+
core.info(` > None`);
35526+
}
3551935527
const versions = getUnityVersionsFromInput(architecture);
3552035528
const versionFilePath = await getVersionFilePath();
3552135529
const unityProjectPath = versionFilePath !== undefined ? path.join(versionFilePath, '..', '..') : undefined;
@@ -35534,6 +35542,9 @@ async function ValidateInputs() {
3553435542
for (const unityVersion of versions) {
3553535543
core.info(` > ${unityVersion.toString()}`);
3553635544
}
35545+
if (versions.length === 0) {
35546+
core.info(` > None`);
35547+
}
3553735548
let installPath = core.getInput('install-path');
3553835549
if (installPath) {
3553935550
installPath = path.normalize(installPath.trim());
@@ -35574,40 +35585,41 @@ function getInstallationArch() {
3557435585
}
3557535586
function getPlatformTargetModuleMap() {
3557635587
const osType = os.type();
35577-
let moduleMap = undefined;
35578-
if (osType == 'Linux') {
35579-
moduleMap = {
35580-
"StandaloneLinux64": "linux-il2cpp",
35581-
"Android": "android",
35582-
"WebGL": "webgl",
35583-
"iOS": "ios",
35584-
};
35585-
}
35586-
else if (osType == 'Darwin') {
35587-
moduleMap = {
35588-
"StandaloneOSX": "mac-il2cpp",
35589-
"iOS": "ios",
35590-
"Android": "android",
35591-
"tvOS": "appletv",
35592-
"StandaloneLinux64": "linux-il2cpp",
35593-
"WebGL": "webgl",
35594-
"VisionOS": "visionos"
35595-
};
35596-
}
35597-
else if (osType == 'Windows_NT') {
35598-
moduleMap = {
35599-
"StandaloneWindows64": "windows-il2cpp",
35600-
"WSAPlayer": "universal-windows-platform",
35601-
"Android": "android",
35602-
"iOS": "ios",
35603-
"tvOS": "appletv",
35604-
"StandaloneLinux64": "linux-il2cpp",
35605-
"Lumin": "lumin",
35606-
"WebGL": "webgl",
35607-
};
35608-
}
35609-
else {
35610-
throw Error(`${osType} not supported`);
35588+
let moduleMap;
35589+
switch (osType) {
35590+
case 'Linux':
35591+
moduleMap = {
35592+
"StandaloneLinux64": "linux-il2cpp",
35593+
"Android": "android",
35594+
"WebGL": "webgl",
35595+
"iOS": "ios",
35596+
};
35597+
break;
35598+
case 'Darwin':
35599+
moduleMap = {
35600+
"StandaloneOSX": "mac-il2cpp",
35601+
"iOS": "ios",
35602+
"Android": "android",
35603+
"tvOS": "appletv",
35604+
"StandaloneLinux64": "linux-il2cpp",
35605+
"WebGL": "webgl",
35606+
"VisionOS": "visionos"
35607+
};
35608+
break;
35609+
case 'Windows_NT':
35610+
moduleMap = {
35611+
"StandaloneWindows64": "windows-il2cpp",
35612+
"WSAPlayer": "universal-windows-platform",
35613+
"Android": "android",
35614+
"iOS": "ios",
35615+
"tvOS": "appletv",
35616+
"StandaloneLinux64": "linux-il2cpp",
35617+
"Lumin": "lumin",
35618+
"WebGL": "webgl",
35619+
};
35620+
break;
35621+
default:
35622+
throw Error(`${osType} not supported`);
3561135623
}
3561235624
return moduleMap;
3561335625
}
@@ -35894,35 +35906,39 @@ function init() {
3589435906
}
3589535907
}
3589635908
async function Get() {
35909+
let isCleanInstall = false;
3589735910
try {
3589835911
await fs.promises.access(hubPath, fs.constants.X_OK);
3589935912
}
3590035913
catch (error) {
3590135914
hubPath = await installUnityHub();
35902-
}
35903-
const hubVersion = await getInstalledHubVersion();
35904-
if (!semver.valid(hubVersion)) {
35905-
throw new Error(`Failed to get installed Unity Hub version ${hubVersion}!`);
35906-
}
35907-
core.info(`Unity Hub Version:\n > ${hubVersion}`);
35908-
const latestHubVersion = await getLatestHubVersion();
35909-
if (!semver.valid(latestHubVersion)) {
35910-
throw new Error(`Failed to get latest Unity Hub version!`);
35911-
}
35912-
core.debug(`Latest Unity Hub Version:\n > ${latestHubVersion}`);
35913-
core.debug(`Comparing versions:\n > ${hubVersion} < ${latestHubVersion} => ${semver.compare(hubVersion, latestHubVersion)}`);
35914-
if (semver.compare(hubVersion, latestHubVersion) < 0) {
35915-
core.info(`Installing Latest Unity Hub Version:\n > ${latestHubVersion}`);
35916-
if (process.platform !== 'linux') {
35917-
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
35918-
await (0, utility_1.RemovePath)(hubPath);
35919-
hubPath = await installUnityHub();
35920-
}
35921-
else {
35922-
const scriptPath = __nccwpck_require__.ab + "update-unityhub-linux.sh";
35923-
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "update-unityhub-linux.sh"]);
35924-
if (exitCode !== 0) {
35925-
throw new Error(`Failed to install Unity Hub: ${exitCode}`);
35915+
isCleanInstall = true;
35916+
}
35917+
if (!isCleanInstall) {
35918+
const hubVersion = await getInstalledHubVersion();
35919+
if (!semver.valid(hubVersion)) {
35920+
throw new Error(`Failed to get installed Unity Hub version ${hubVersion}!`);
35921+
}
35922+
core.info(`Installed Unity Hub Version:\n > ${hubVersion}`);
35923+
const latestHubVersion = await getLatestHubVersion();
35924+
if (!semver.valid(latestHubVersion)) {
35925+
throw new Error(`Failed to get latest Unity Hub version!`);
35926+
}
35927+
core.debug(`Latest Unity Hub Version:\n > ${latestHubVersion}`);
35928+
core.debug(`Comparing versions:\n > ${hubVersion} < ${latestHubVersion} => ${semver.compare(hubVersion, latestHubVersion)}`);
35929+
if (semver.compare(hubVersion, latestHubVersion) < 0) {
35930+
core.info(`Installing Latest Unity Hub Version:\n > ${latestHubVersion}`);
35931+
if (process.platform !== 'linux') {
35932+
core.info(`Removing previous Unity Hub version:\n > ${hubVersion}`);
35933+
await (0, utility_1.RemovePath)(hubPath);
35934+
hubPath = await installUnityHub();
35935+
}
35936+
else {
35937+
const scriptPath = __nccwpck_require__.ab + "update-unityhub-linux.sh";
35938+
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "update-unityhub-linux.sh"]);
35939+
if (exitCode !== 0) {
35940+
throw new Error(`Failed to install Unity Hub: ${exitCode}`);
35941+
}
3592635942
}
3592735943
}
3592835944
}
@@ -36214,6 +36230,15 @@ async function installUnity(unityVersion, modules) {
3621436230
return await installUnity4x(unityVersion);
3621536231
}
3621636232
core.startGroup(`Installing Unity ${unityVersion.toString()}...`);
36233+
if (process.platform === 'linux') {
36234+
const installLinuxDepsScript = __nccwpck_require__.ab + "install-linux-dependencies.sh";
36235+
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "install-linux-dependencies.sh", unityVersion.version], {
36236+
ignoreReturnCode: true
36237+
});
36238+
if (exitCode !== 0) {
36239+
throw new Error(`Failed to install additional Linux dependencies for Unity ${unityVersion.toString()}: ${exitCode}`);
36240+
}
36241+
}
3621736242
const args = ['install', '--version', unityVersion.version];
3621836243
if (unityVersion.changeset) {
3621936244
args.push('--changeset', unityVersion.changeset);
@@ -36248,7 +36273,9 @@ async function installUnity4x(unityVersion) {
3624836273
const installPath = path.join(installDir, `Unity ${unityVersion.version}`);
3624936274
if (!fs.existsSync(installPath)) {
3625036275
const scriptPath = __nccwpck_require__.ab + "unity-editor-installer.ps1";
36251-
const exitCode = await exec.exec('pwsh', [__nccwpck_require__.ab + "unity-editor-installer.ps1", unityVersion.version, installDir]);
36276+
const exitCode = await exec.exec('pwsh', [__nccwpck_require__.ab + "unity-editor-installer.ps1", unityVersion.version, installDir], {
36277+
ignoreReturnCode: true
36278+
});
3625236279
if (exitCode !== 0) {
3625336280
throw new Error(`Failed to install Unity ${unityVersion.toString()}: ${exitCode}`);
3625436281
}
@@ -36261,8 +36288,9 @@ async function installUnity4x(unityVersion) {
3626136288
const installPath = path.join(installDir, `Unity ${unityVersion.version}`, 'Unity.app');
3626236289
if (!fs.existsSync(installPath)) {
3626336290
const scriptPath = __nccwpck_require__.ab + "unity-editor-installer.sh";
36264-
await fs.promises.chmod(__nccwpck_require__.ab + "unity-editor-installer.sh", 0o755);
36265-
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "unity-editor-installer.sh", unityVersion.version, installDir]);
36291+
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "unity-editor-installer.sh", unityVersion.version, installDir], {
36292+
ignoreReturnCode: true
36293+
});
3626636294
if (exitCode !== 0) {
3626736295
throw new Error(`Failed to install Unity ${unityVersion.toString()}: ${exitCode}`);
3626836296
}
@@ -36441,26 +36469,25 @@ async function getEditorReleaseInfo(unityVersion) {
3644136469
return results[0];
3644236470
}
3644336471
async function fallbackVersionLookup(unityVersion) {
36444-
let version = unityVersion.version.split('.')[0];
36445-
if (/^\d{1,4}\.0(\.0)?$/.test(unityVersion.version)) {
36446-
version = unityVersion.version.split('.')[0];
36447-
}
36448-
const url = `https://unity.com/releases/editor/whats-new/${version}`;
36472+
const url = `https://unity.com/releases/editor/whats-new/${unityVersion.version}`;
3644936473
core.debug(`Fetching release page: "${url}"`);
3645036474
let response;
3645136475
try {
3645236476
response = await fetch(url);
3645336477
}
3645436478
catch (error) {
36455-
core.warning(`Failed to fetch changeset for Unity ${unityVersion.toString()} [network error]: ${error}`);
36479+
core.warning(`Failed to fetch changeset for Unity ${unityVersion.toString()}: ${error}`);
3645636480
return unityVersion;
3645736481
}
36482+
const responseText = await response.text();
36483+
if (core.isDebug()) {
36484+
core.info(responseText);
36485+
}
3645836486
if (!response.ok) {
36459-
throw new Error(`Failed to fetch changeset [${response.status}] "${url}"`);
36487+
throw new Error(`Failed to fetch changeset for Unity ${unityVersion.toString()} [${response.status}] "${url}"`);
3646036488
}
36461-
const data = await response.text();
36462-
core.debug(`Release page content:\n${data}`);
36463-
const match = data.match(/unityhub:\/\/(?<version>\d+\.\d+\.\d+[abcfpx]?\d*)\/(?<changeset>[a-zA-Z0-9]+)/);
36489+
core.debug(`Release page content: \n${responseText}`);
36490+
const match = responseText.match(/unityhub:\/\/(?<version>\d+\.\d+\.\d+[abcfpx]?\d*)\/(?<changeset>[a-zA-Z0-9]+)/);
3646436491
if (match && match.groups && match.groups.changeset) {
3646536492
return new unity_version_1.UnityVersion(match.groups.version, match.groups.changeset, unityVersion.architecture);
3646636493
}

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-linux-dependencies.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
## installs additional dependencies required for Unity on Linux
3+
## usage: install-linux-dependencies.sh <unity-version>
4+
set -e
5+
6+
unityVersion="$1"
7+
8+
if [ -z "$unityVersion" ]; then
9+
echo "Usage: $0 <unity-version>"
10+
exit 1
11+
fi
12+
13+
echo "::group::Installing additional dependencies for Unity $unityVersion..."
14+
15+
# Unity 2019.{1,2}
16+
if [[ "$unityVersion" =~ ^2019\.[12]\. ]]; then
17+
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
18+
sudo dpkg -i libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
19+
rm libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
20+
fi
21+
22+
# Unity 2019.{3,4}/2020.*
23+
if [[ "$unityVersion" =~ ^2019\.[34]\. ]] || [[ "$unityVersion" =~ ^2020\. ]]; then
24+
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
25+
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
26+
rm libssl1.1_1.1.0g-2ubuntu4_amd64.deb
27+
fi
28+
29+
echo "::endgroup::"

0 commit comments

Comments
 (0)