@@ -34121,10 +34121,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
34121
34121
exports.ValidateInputs = ValidateInputs;
34122
34122
const utility_1 = __nccwpck_require__(5418);
34123
34123
const core = __nccwpck_require__(2186);
34124
- const semver = __nccwpck_require__(1383);
34125
34124
const path = __nccwpck_require__(1017);
34126
34125
const os = __nccwpck_require__(2037);
34127
34126
const fs = __nccwpck_require__(7147);
34127
+ const unity_version_1 = __nccwpck_require__(5988);
34128
34128
async function ValidateInputs() {
34129
34129
const modules = [];
34130
34130
const architecture = core.getInput('architecture') || getInstallationArch();
@@ -34168,16 +34168,15 @@ async function ValidateInputs() {
34168
34168
if (versionFilePath) {
34169
34169
core.info(`versionFilePath:\n > "${versionFilePath}"`);
34170
34170
core.info(`Unity Project Path:\n > "${unityProjectPath}"`);
34171
- const [ unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
34171
+ const unityVersion = await getUnityVersionFromFile(versionFilePath);
34172
34172
if (versions.length === 0) {
34173
- versions.push([ unityVersion, changeset] );
34173
+ versions.push(unityVersion);
34174
34174
}
34175
34175
}
34176
- versions.sort(([a], [b]) => semver. compare(a, b, true) );
34176
+ versions.sort(unity_version_1.UnityVersion. compare);
34177
34177
core.info(`Unity Versions:`);
34178
- for (const [version, changeset] of versions) {
34179
- const changesetStr = changeset ? ` (${changeset})` : '';
34180
- core.info(` > ${version}${changesetStr}`);
34178
+ for (const unityVersion of versions) {
34179
+ core.info(` > ${unityVersion.toString()}`);
34181
34180
}
34182
34181
let installPath = core.getInput('install-path');
34183
34182
if (installPath) {
@@ -34317,7 +34316,7 @@ function getUnityVersionsFromInput() {
34317
34316
const changeset = match.groups.changeset;
34318
34317
const changesetStr = changeset ? ` (${changeset})` : '';
34319
34318
core.debug(`${version}${changesetStr}`);
34320
- versions.push([ version, changeset] );
34319
+ versions.push(new unity_version_1.UnityVersion( version, changeset) );
34321
34320
}
34322
34321
return versions;
34323
34322
}
@@ -34334,7 +34333,7 @@ async function getUnityVersionFromFile(versionFilePath) {
34334
34333
if (!match.groups.changeset) {
34335
34334
throw Error(`No changeset group found!`);
34336
34335
}
34337
- return [ match.groups.version, match.groups.changeset] ;
34336
+ return new unity_version_1.UnityVersion( match.groups.version, match.groups.changeset) ;
34338
34337
}
34339
34338
34340
34339
@@ -34479,6 +34478,7 @@ exports.SetInstallPath = SetInstallPath;
34479
34478
exports.Unity = Unity;
34480
34479
exports.ListInstalledEditors = ListInstalledEditors;
34481
34480
const utility_1 = __nccwpck_require__(5418);
34481
+ const unity_version_1 = __nccwpck_require__(5988);
34482
34482
const asar = __nccwpck_require__(6561);
34483
34483
const core = __nccwpck_require__(2186);
34484
34484
const exec = __nccwpck_require__(1514);
@@ -34559,6 +34559,10 @@ async function SetInstallPath(installPath) {
34559
34559
await fs.promises.mkdir(installPath, { recursive: true });
34560
34560
await execUnityHub(["install-path", "--set", installPath]);
34561
34561
}
34562
+ async function getInstallPath() {
34563
+ const result = await execUnityHub(["install-path", "--get"]);
34564
+ return result.trim();
34565
+ }
34562
34566
async function installUnityHub() {
34563
34567
let exitCode = undefined;
34564
34568
switch (process.platform) {
@@ -34724,34 +34728,33 @@ const retryErrorMessages = [
34724
34728
'Editor already installed in this location',
34725
34729
'failed to download. Error given: Request timeout'
34726
34730
];
34727
- async function Unity(version, changeset , architecture, modules) {
34728
- if (os.arch() == 'arm64' && !isArmCompatible(version)) {
34729
- core.warning (`Unity ${version } does not support arm64 architecture, falling back to x86_64`);
34731
+ async function Unity(unityVersion , architecture, modules) {
34732
+ if (os.arch() == 'arm64' && !isArmCompatible(unityVersion. version)) {
34733
+ core.info (`Unity ${unityVersion.toString() } does not support arm64 architecture, falling back to x86_64`);
34730
34734
architecture = 'x86_64';
34731
34735
}
34732
- if (!changeset) {
34733
- core.debug(`Fetching changeset for Unity ${version }...`);
34734
- changeset = await getChangeset(version );
34736
+ if (!unityVersion. changeset) {
34737
+ core.debug(`Fetching changeset for Unity ${unityVersion.toString() }...`);
34738
+ unityVersion = await getChangeset(unityVersion );
34735
34739
}
34736
- let editorPath = await checkInstalledEditors(version, architecture, false);
34740
+ let editorPath = await checkInstalledEditors(unityVersion. version, architecture, false);
34737
34741
if (!editorPath) {
34738
34742
try {
34739
- await installUnity(version, changeset , architecture, modules);
34743
+ await installUnity(unityVersion , architecture, modules);
34740
34744
}
34741
34745
catch (error) {
34742
34746
if (retryErrorMessages.some(msg => error.message.includes(msg))) {
34743
34747
await removePath(editorPath);
34744
- await installUnity(version, changeset , architecture, modules);
34748
+ await installUnity(unityVersion , architecture, modules);
34745
34749
}
34746
34750
}
34747
- editorPath = await checkInstalledEditors(version, architecture);
34751
+ editorPath = await checkInstalledEditors(unityVersion. version, architecture);
34748
34752
}
34749
34753
await fs.promises.access(editorPath, fs.constants.X_OK);
34750
34754
core.info(`Unity Editor Path:\n > "${editorPath}"`);
34751
34755
try {
34752
- const changesetStr = changeset ? ` (${changeset})` : '';
34753
- core.startGroup(`Checking installed modules for Unity ${version}${changesetStr}...`);
34754
- const [installedModules, additionalModules] = await checkEditorModules(editorPath, version, architecture, modules);
34756
+ core.startGroup(`Checking installed modules for Unity ${unityVersion.toString()}...`);
34757
+ const [installedModules, additionalModules] = await checkEditorModules(editorPath, unityVersion.version, architecture, modules);
34755
34758
if (installedModules && installedModules.length > 0) {
34756
34759
core.info(`Installed Modules:`);
34757
34760
for (const module of installedModules) {
@@ -34779,37 +34782,89 @@ async function Unity(version, changeset, architecture, modules) {
34779
34782
catch (error) {
34780
34783
if (error.message.includes(`No modules found`)) {
34781
34784
removePath(editorPath);
34782
- await Unity(version, changeset , architecture, modules);
34785
+ await Unity(unityVersion , architecture, modules);
34783
34786
}
34784
34787
}
34785
34788
finally {
34786
34789
core.endGroup();
34787
34790
}
34788
34791
return editorPath;
34789
34792
}
34790
- async function installUnity(version, changeset, architecture, modules) {
34791
- core.startGroup(`Installing Unity ${version} (${changeset})...`);
34792
- const args = ['install', '--version', version];
34793
- if (changeset) {
34794
- args.push('--changeset', changeset);
34793
+ async function parseReleases(version, data) {
34794
+ const releases = JSON.parse(data);
34795
+ core.debug(`Found ${releases.official.length} official releases...`);
34796
+ releases.official.sort((a, b) => semver.compare(a.version, b.version, true));
34797
+ for (const release of releases.official) {
34798
+ const semVersion = semver.coerce(version);
34799
+ const semVerRelease = semver.coerce(release.version);
34800
+ core.debug(`Checking ${semVersion} against ${semVerRelease}`);
34801
+ if (semver.satisfies(semVerRelease, `^${semVersion}`)) {
34802
+ core.debug(`Found Unity ${release.version} release.`);
34803
+ const match = release.downloadUrl.match(/download_unity\/(?<changeset>[a-zA-Z0-9]+)\//);
34804
+ if (match && match.groups && match.groups.changeset) {
34805
+ const changeset = match.groups.changeset;
34806
+ core.debug(`Found Unity ${release.version} (${changeset})`);
34807
+ return new unity_version_1.UnityVersion(release.version, changeset);
34808
+ }
34809
+ }
34810
+ }
34811
+ throw new Error(`Failed to find Unity ${version} release. Please provide a valid changeset.`);
34812
+ }
34813
+ async function installUnity(unityVersion, architecture, modules) {
34814
+ if (semver.major(unityVersion.version, { loose: true }) === 4) {
34815
+ return await installUnity4x(unityVersion);
34816
+ }
34817
+ core.startGroup(`Installing Unity ${unityVersion.toString()}...`);
34818
+ const args = ['install', '--version', unityVersion.version];
34819
+ if (unityVersion.changeset) {
34820
+ args.push('--changeset', unityVersion.changeset);
34795
34821
}
34796
34822
if (architecture) {
34797
34823
args.push('-a', architecture);
34798
34824
}
34799
- for (const module of modules) {
34800
- core.info(` > with module: ${module}`);
34801
- args.push('-m', module);
34825
+ if (modules.length > 0) {
34826
+ for (const module of modules) {
34827
+ core.info(` > with module: ${module}`);
34828
+ args.push('-m', module);
34829
+ }
34830
+ args.push('--cm');
34802
34831
}
34803
34832
try {
34804
- const output = await execUnityHub([... args, '--cm'] );
34833
+ const output = await execUnityHub(args);
34805
34834
if (output.includes(`Error while installing an editor or a module from changeset`)) {
34806
- throw new Error(`Failed to install Unity ${version} (${changeset}) `);
34835
+ throw new Error(`Failed to install Unity ${unityVersion.toString()} `);
34807
34836
}
34808
34837
}
34809
34838
finally {
34810
34839
core.endGroup();
34811
34840
}
34812
34841
}
34842
+ async function installUnity4x(unityVersion) {
34843
+ const installPath = await getInstallPath();
34844
+ switch (process.platform) {
34845
+ case 'linux':
34846
+ throw new Error(`Unity ${unityVersion.toString()} is not supported on Linux!`);
34847
+ case 'win32':
34848
+ {
34849
+ const scriptPath = __nccwpck_require__.ab + "unity-editor-installer.ps1";
34850
+ const exitCode = await exec.exec('pwsh', [__nccwpck_require__.ab + "unity-editor-installer.ps1", unityVersion.version, installPath]);
34851
+ if (exitCode !== 0) {
34852
+ throw new Error(`Failed to install Unity ${unityVersion.toString()}: ${exitCode}`);
34853
+ }
34854
+ break;
34855
+ }
34856
+ case 'darwin':
34857
+ {
34858
+ const scriptPath = __nccwpck_require__.ab + "unity-editor-installer.sh";
34859
+ await fs.promises.chmod(__nccwpck_require__.ab + "unity-editor-installer.sh", 0o755);
34860
+ const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "unity-editor-installer.sh", unityVersion.version, installPath]);
34861
+ if (exitCode !== 0) {
34862
+ throw new Error(`Failed to install Unity ${unityVersion.toString()}: ${exitCode}`);
34863
+ }
34864
+ break;
34865
+ }
34866
+ }
34867
+ }
34813
34868
async function ListInstalledEditors() {
34814
34869
return await execUnityHub(['editors', '-i']);
34815
34870
}
@@ -34902,20 +34957,20 @@ async function getModulesContent(modulesPath) {
34902
34957
const modulesContent = await (0, utility_1.ReadFileContents)(modulesPath);
34903
34958
return JSON.parse(modulesContent);
34904
34959
}
34905
- async function getChangeset(version ) {
34906
- version = version.split(/[abf]/)[0];
34907
- const url = `https://unity.com/releases/editor/whats-new/${version }`;
34960
+ async function getChangeset(unityVersion ) {
34961
+ const splitVersion = unityVersion. version.split(/[abf]/)[0];
34962
+ const url = `https://unity.com/releases/editor/whats-new/${splitVersion }`;
34908
34963
const response = await fetch(url);
34909
34964
if (!response.ok) {
34910
34965
throw new Error(`Failed to fetch changeset [${response.status}] "${url}"`);
34911
34966
}
34912
34967
const data = await response.text();
34913
34968
const match = data.match(/unityhub:\/\/(?<version>\d+\.\d+\.\d+[fab]?\d*)\/(?<changeset>[a-zA-Z0-9]+)/);
34914
34969
if (match && match.groups && match.groups.changeset) {
34915
- return match.groups.changeset;
34970
+ return new unity_version_1.UnityVersion( match.groups.version, match.groups. changeset) ;
34916
34971
}
34917
- core.error(`Failed to find changeset for Unity ${version }`);
34918
- return null ;
34972
+ core.error(`Failed to find changeset for Unity ${unityVersion.toString() }`);
34973
+ return unityVersion ;
34919
34974
}
34920
34975
async function removePath(targetPath) {
34921
34976
if (targetPath && targetPath.length > 0) {
@@ -34930,6 +34985,30 @@ async function removePath(targetPath) {
34930
34985
}
34931
34986
34932
34987
34988
+ /***/ }),
34989
+
34990
+ /***/ 5988:
34991
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
34992
+
34993
+ "use strict";
34994
+
34995
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
34996
+ exports.UnityVersion = void 0;
34997
+ const semver = __nccwpck_require__(1383);
34998
+ class UnityVersion {
34999
+ constructor(version, changeset) {
35000
+ this.version = version;
35001
+ this.changeset = changeset;
35002
+ }
35003
+ static compare(a, b) {
35004
+ const vA = a.version;
35005
+ const vB = b.version;
35006
+ return semver.compare(vA, vB) || vA.localeCompare(vB);
35007
+ }
35008
+ }
35009
+ exports.UnityVersion = UnityVersion;
35010
+
35011
+
34933
35012
/***/ }),
34934
35013
34935
35014
/***/ 5418:
@@ -45547,13 +45626,13 @@ const main = async () => {
45547
45626
await unityHub.SetInstallPath(installPath);
45548
45627
}
45549
45628
const editors = [];
45550
- for (const [version, changeset] of versions) {
45551
- const unityEditorPath = await unityHub.Unity(version, changeset , architecture, modules);
45629
+ for (const unityVersion of versions) {
45630
+ const unityEditorPath = await unityHub.Unity(unityVersion , architecture, modules);
45552
45631
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath);
45553
45632
if (modules.includes('android') && unityProjectPath !== undefined) {
45554
45633
await (0, install_android_sdk_1.CheckAndroidSdkInstalled)(unityEditorPath, unityProjectPath);
45555
45634
}
45556
- editors.push([version, unityEditorPath]);
45635
+ editors.push([unityVersion. version, unityEditorPath]);
45557
45636
}
45558
45637
const installedEditors = editors.map(([version, path]) => `\"${version}\":\"${path}\"`).join(',');
45559
45638
core.exportVariable('UNITY_EDITORS', `[${installedEditors}]`);
0 commit comments