Skip to content

Commit 03035e7

Browse files
StephenHodgsonCopilotjs6pak
authored
- add support for installing unity 5.x versions - add `install-path` input parameter --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: js6pak <[email protected]>
1 parent d9287e7 commit 03035e7

14 files changed

+144
-25
lines changed

.github/workflows/validate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
os: [ubuntu-latest, windows-latest, macos-latest]
2828
unity-versions:
2929
- 'in version file'
30+
- '5.6.7f1 (e80cc3114ac1)'
3031
- 2019.4.40f1
3132
- 2020.3
3233
- 2021.3.x
@@ -42,6 +43,10 @@ jobs:
4243
- os: macos-latest
4344
build-targets: StandaloneOSX Android iOS VisionOS
4445
modules: mac-server
46+
exclude:
47+
# Exclude Unity 5.x for linux as it is not supported
48+
- os: ubuntu-latest
49+
unity-versions: '5.6.7f1 (e80cc3114ac1)'
4550
steps:
4651
- uses: actions/checkout@v4
4752

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ steps:
5454
| `build-targets` | Specify the build targets to install for. Remaps to corresponding module. One or more of `StandaloneWindows64` `WSAPlayer` `StandaloneOSX` `iOS` `StandaloneLinux64` `Android` `Lumin` `WebGL` `VisionOS`. | false |
5555
| `modules` | Modules to install with the editor. This list can be different per editor version. | false |
5656
| `architecture` | Specify the architecture to install. Either `x86_64` or `arm64`. | false |
57+
| `install-path` | Specify the path where Unity will be installed to. | false |
5758

5859
### outputs
5960

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ inputs:
2424
description: 'Specify the architecture to install. Either `x86_64` or `arm64`.'
2525
required: false
2626
default: ''
27+
install-path:
28+
description: 'Specify the path where Unity will be installed to.'
29+
required: false
2730
runs:
2831
using: 'node20'
2932
main: 'dist/index.js'

dist/index.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5754,7 +5754,7 @@ function expand(str, isTop) {
57545754
var isOptions = m.body.indexOf(',') >= 0;
57555755
if (!isSequence && !isOptions) {
57565756
// {a},b}
5757-
if (m.post.match(/,.*\}/)) {
5757+
if (m.post.match(/,(?!,).*\}/)) {
57585758
str = m.pre + '{' + m.body + escClose + m.post;
57595759
return expand(str);
57605760
}
@@ -34181,7 +34181,20 @@ async function ValidateInputs() {
3418134181
const changesetStr = changeset ? ` (${changeset})` : '';
3418234182
core.info(` > ${version}${changesetStr}`);
3418334183
}
34184-
return [versions, architecture, modules, unityProjectPath];
34184+
let installPath = core.getInput('install-path');
34185+
if (installPath) {
34186+
installPath = installPath.trim();
34187+
if (installPath.length === 0) {
34188+
installPath = undefined;
34189+
}
34190+
else {
34191+
core.info(`Install Path:\n > "${installPath}"`);
34192+
}
34193+
}
34194+
if (!installPath) {
34195+
core.debug('No install path specified, using default Unity Hub install path.');
34196+
}
34197+
return [versions, architecture, modules, unityProjectPath, installPath];
3418534198
}
3418634199
function getArrayInput(key) {
3418734200
let input = core.getInput(key);
@@ -34464,6 +34477,7 @@ async function execSdkManager(sdkManagerPath, javaSdk, args) {
3446434477

3446534478
Object.defineProperty(exports, "__esModule", ({ value: true }));
3446634479
exports.Get = Get;
34480+
exports.setInstallPath = setInstallPath;
3446734481
exports.Unity = Unity;
3446834482
exports.ListInstalledEditors = ListInstalledEditors;
3446934483
const utility_1 = __nccwpck_require__(5418);
@@ -34704,6 +34718,14 @@ async function execUnityHub(args) {
3470434718
}
3470534719
return output;
3470634720
}
34721+
const retryErrorMessages = [
34722+
'Editor already installed in this location',
34723+
'failed to download. Error given: Request timeout'
34724+
];
34725+
async function setInstallPath(installPath) {
34726+
await fs.promises.mkdir(installPath, { recursive: true });
34727+
await execUnityHub(["install-path", "--set", installPath]);
34728+
}
3470734729
async function Unity(version, changeset, architecture, modules) {
3470834730
if (os.arch() == 'arm64' && !isArmCompatible(version)) {
3470934731
core.warning(`Unity ${version} does not support arm64 architecture, falling back to x86_64`);
@@ -34724,8 +34746,8 @@ async function Unity(version, changeset, architecture, modules) {
3472434746
await installUnity(version, changeset, architecture, modules);
3472534747
}
3472634748
catch (error) {
34727-
if (error.message.includes('Editor already installed in this location')) {
34728-
removePath(editorPath);
34749+
if (retryErrorMessages.some(msg => error.message.includes(msg))) {
34750+
await removePath(editorPath);
3472934751
await installUnity(version, changeset, architecture, modules);
3473034752
}
3473134753
}
@@ -34749,6 +34771,17 @@ async function Unity(version, changeset, architecture, modules) {
3474934771
core.info(` > ${module}`);
3475034772
}
3475134773
}
34774+
if (process.platform === 'linux') {
34775+
const dataPath = path.join(path.dirname(editorPath), 'Data');
34776+
const beeBackend = path.join(dataPath, 'bee_backend');
34777+
const dotBeeBackend = path.join(dataPath, '.bee_backend');
34778+
if (fs.existsSync(beeBackend) && !fs.existsSync(dotBeeBackend)) {
34779+
await fs.promises.rename(beeBackend, dotBeeBackend);
34780+
const wrapperSource = __nccwpck_require__.ab + "linux-bee-backend-wrapper.sh";
34781+
await fs.promises.copyFile(__nccwpck_require__.ab + "linux-bee-backend-wrapper.sh", beeBackend);
34782+
await fs.promises.chmod(beeBackend, 0o755);
34783+
}
34784+
}
3475234785
}
3475334786
catch (error) {
3475434787
if (error.message.includes(`No modules found`)) {
@@ -45558,12 +45591,15 @@ const unityHub = __nccwpck_require__(2754);
4555845591
const core = __nccwpck_require__(2186);
4555945592
const main = async () => {
4556045593
try {
45561-
const [versions, architecture, modules, unityProjectPath] = await (0, inputs_1.ValidateInputs)();
45594+
const [versions, architecture, modules, unityProjectPath, installPath] = await (0, inputs_1.ValidateInputs)();
4556245595
if (unityProjectPath) {
4556345596
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
4556445597
}
4556545598
const unityHubPath = await unityHub.Get();
4556645599
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
45600+
if (installPath.length > 0) {
45601+
await unityHub.setInstallPath(installPath);
45602+
}
4556745603
const editors = [];
4556845604
for (const [version, changeset] of versions) {
4556945605
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ sudo sh -c 'dbus-uuidgen >/etc/machine-id && mkdir -p /var/lib/dbus/ && ln -sf /
44
echo "::group::Installing Unity Hub..."
55
wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | sudo tee /usr/share/keyrings/Unity_Technologies_ApS.gpg >/dev/null
66
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'
7+
echo "deb https://archive.ubuntu.com/ubuntu jammy main universe" | sudo tee /etc/apt/sources.list.d/jammy.list
78
sudo apt-get update
8-
sudo apt-get install -y --no-install-recommends unityhub ffmpeg
9+
sudo apt-get install -y --no-install-recommends unityhub ffmpeg libgtk2.0-0 libglu1-mesa libgconf-2-4 libncurses5
910
sudo apt-get clean
11+
# Unity 2019.x/2020.x
12+
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
13+
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
14+
rm libssl1.1_1.1.0g-2ubuntu4_amd64.deb
1015
sudo sed -i 's/^\(.*DISPLAY=:.*XAUTHORITY=.*\)\( "\$@" \)2>&1$/\1\2/' /usr/bin/xvfb-run
1116
sudo printf '#!/bin/bash\nxvfb-run --auto-servernum /opt/unityhub/unityhub "$@" 2>/dev/null' | sudo tee /usr/bin/unity-hub >/dev/null
1217
sudo chmod 777 /usr/bin/unity-hub

dist/linux-bee-backend-wrapper.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# https://discussions.unity.com/t/linux-editor-stuck-on-loading-because-of-bee-backend-w-workaround/854480
3+
set -e
4+
args=("$@")
5+
for ((i = 0; i < "${#args[@]}"; ++i)); do
6+
case ${args[i]} in
7+
--stdin-canary)
8+
unset "args[i]"
9+
break
10+
;;
11+
esac
12+
done
13+
"$(dirname "$0")/.$(basename "$0")" "${args[@]}"

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "1.0.14",
3+
"version": "1.1.0",
44
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",
@@ -32,7 +32,7 @@
3232
"yaml": "^2.8.0"
3333
},
3434
"devDependencies": {
35-
"@types/node": "^22.15.18",
35+
"@types/node": "^22.16.3",
3636
"@types/semver": "^7.7.0",
3737
"@vercel/ncc": "^0.34.0",
3838
"shx": "^0.3.4",
@@ -44,4 +44,4 @@
4444
"watch": "ncc build src/index.ts -o dist --source-map --license licenses.txt --watch",
4545
"clean": "npm install && shx rm -rf dist/ out/ node_modules/ && npm ci"
4646
}
47-
}
47+
}

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import core = require('@actions/core');
55

66
const main = async () => {
77
try {
8-
const [versions, architecture, modules, unityProjectPath] = await ValidateInputs();
8+
const [versions, architecture, modules, unityProjectPath, installPath] = await ValidateInputs();
99
if (unityProjectPath) {
1010
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
1111
}
1212
const unityHubPath = await unityHub.Get();
1313
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
14+
15+
if (installPath.length > 0) {
16+
await unityHub.setInstallPath(installPath);
17+
}
18+
1419
const editors = [];
1520
for (const [version, changeset] of versions) {
1621
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);

0 commit comments

Comments
 (0)