Skip to content

Commit b3711a6

Browse files
authored
Fix Unity installation error on Linux (#552)
1 parent 2f1b69e commit b3711a6

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

.github/workflows/build_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ on:
3838
jobs:
3939
build_desktop:
4040
name: build-linux-unity${{inputs.unity_version}}-CPP${{ inputs.firebase_cpp_sdk_version }}
41-
runs-on: ubuntu-20.04
41+
runs-on: ubuntu-latest
4242
strategy:
4343
fail-fast: false
4444

gha/unity/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version, e.g. `2020.
1919

2020
- Output usage:
2121
```yml
22-
- uses: firebase/firebase-unity-sdk/gha/unity@main
22+
- uses: ./gha/unity
2323
with:
2424
version: ${{ unity_version }}
2525
platforms: ${{ platforms }}
@@ -37,13 +37,13 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version, e.g. `2020.
3737

3838
steps:
3939
# ...
40-
- uses: firebase/firebase-unity-sdk/gha/unity@main
40+
- uses: ./gha/unity
4141
with:
4242
version: ${{ unity_version }}
4343
platforms: ${{ platforms }}
4444
```
4545
46-
- Install Unity, Activate and Release Unity License
46+
- Install Unity, Activate and Release Unity License. Always release the license after usage.
4747
```yml
4848
jobs:
4949
build_testapp:
@@ -52,7 +52,7 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version, e.g. `2020.
5252
steps:
5353
# ...
5454
- id: unity_setup_and_activate
55-
uses: firebase/firebase-unity-sdk/gha/unity@main
55+
uses: ./gha/unity
5656
with:
5757
version: ${{ unity_version }}
5858
platforms: ${{ platforms }}
@@ -61,7 +61,7 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version, e.g. `2020.
6161
serial_ids: ${{ secrets.SERIAL_ID }}
6262
# ...
6363
- id: release_license
64-
uses: firebase/firebase-unity-sdk/gha/unity@main
64+
uses: ./gha/unity
6565
with:
6666
version: ${{ unity_version }}
6767
release_license: "true"
@@ -72,18 +72,21 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version, e.g. `2020.
7272
7373
This GitHub Action leverages [Unity Hub](https://unity3d.com/get-unity/download), which is a standalone application that streamlines the way you navigate, download, and manage your Unity projects and installations. Unity Hub is with beta version CLI support, and we are using it for Unity versions management.
7474
75-
In this GitHub Action, supported Unity Versions are maintained by `SETTINGS` in `gha/unity/unity_installer.py`.
75+
In this GitHub Action, supported Unity Versions are maintained by `SETTINGS` in [`gha/unity/unity_installer.py`](https://github.com/firebase/firebase-unity-sdk/blob/unity-readme/gha/unity/unity_installer.py#L89).
7676

7777
**Add a new Unity version support**
7878

79-
1. Select your version from [Unity LTS versions list](https://unity3d.com/unity/qa/lts-releases) and make sure this version can be installed with Unity Hub.
79+
1. Select your version from [Unity LTS versions list](https://unity3d.com/unity/qa/lts-releases):
80+
- Make sure this version can be installed with Unity Hub.
81+
- Make sure this version works on you computer first.
82+
- You may need to select different versions for different OS.
8083

81-
2. Generate new JSON string and added it to `UNITY_SETTINGS`:
84+
2. Generate a JSON string which contains the following information and added it to `UNITY_SETTINGS`:
8285
- `Major_version_number`: unity major version number: `2020`, `2021`, etc.
8386
- `Full_version_number`: unity full version number. e.g. `2020.3.34f1` for major version `2020`.
8487
- `Changeset`: changeset locates at the bottom of this page https://unity3d.com/unity/whats-new/{unity_version}. Note: the version is neither `Major_version_number` nor `Full_version_number`. e.g. https://unity3d.com/unity/whats-new/2020.3.34
8588
- `Platform`: Firebase Unity SDK supported platforms. Values of [Android,iOS,tvOS,Windows,macOS,Linux]
86-
- `Modules`:[Unity Hub must been installed] Unity modules that required for certain platform. e.g. ["windows-mono"] module for "Windows" platform. To list avaliable modules, run `"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" -- --headless help` on your mac machine.
89+
- `Modules`:[Unity Hub must been installed] Unity modules that required for certain platform. e.g. ["windows-mono"] module for "Windows" platform. To list avaliable modules on mac machines, run `"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" -- --headless help` .
8790

8891
Template:
8992
```

gha/unity/unity_installer.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@
9191
"unity_hub_url": {
9292
WINDOWS: "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe",
9393
MACOS: "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg",
94-
LINUX: "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage",
94+
LINUX: "",
9595
},
9696
# Unity Hub will be installed at this location
9797
"unity_hub_path": {
9898
WINDOWS: '"C:/Program Files/Unity Hub/Unity Hub.exe"',
9999
MACOS: '"/Applications/Unity Hub.app"',
100-
LINUX: '"/home/runner/Unity Hub/UnityHub.AppImage"',
100+
LINUX: '/usr/bin/unityhub',
101101
},
102102
"unity_hub_executable": {
103103
WINDOWS: '"C:/Program Files/Unity Hub/Unity Hub.exe" -- --headless',
104104
MACOS: '"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" -- --headless',
105-
LINUX: 'xvfb-run --auto-servernum "/home/runner/Unity Hub/UnityHub.AppImage" --headless',
105+
LINUX: 'xvfb-run unityhub --headless',
106106
},
107107
# Unity will be installed at this location
108108
"unity_path": {
@@ -241,8 +241,9 @@ def install(unity_version, platforms):
241241
def install_unity_hub():
242242
runner_os = get_os()
243243
unity_hub_url = SETTINGS["unity_hub_url"][runner_os]
244-
unity_hub_installer = path.basename(unity_hub_url)
245-
download_unity_hub(unity_hub_url, unity_hub_installer, max_attempts=MAX_ATTEMPTS)
244+
if unity_hub_url:
245+
unity_hub_installer = path.basename(unity_hub_url)
246+
download_unity_hub(unity_hub_url, unity_hub_installer, max_attempts=MAX_ATTEMPTS)
246247
if runner_os == MACOS:
247248
run(f'sudo hdiutil attach {unity_hub_installer}', max_attempts=MAX_ATTEMPTS)
248249
mounted_to = glob.glob("/Volumes/Unity Hub*/Unity Hub.app")
@@ -253,13 +254,11 @@ def install_unity_hub():
253254
elif runner_os == WINDOWS:
254255
run(f'{unity_hub_installer} /S', max_attempts=MAX_ATTEMPTS)
255256
elif runner_os == LINUX:
256-
home_dir = os.environ["HOME"]
257-
unity_hub_path = SETTINGS["unity_hub_path"][runner_os]
258-
run(f'mkdir -p "{home_dir}/Unity Hub" "{home_dir}/.config/Unity Hub"')
259-
run(f'mv {unity_hub_installer} {unity_hub_path}')
260-
run(f'chmod +x {unity_hub_path}')
261-
run(f'touch "{home_dir}/.config/Unity Hub/eulaAccepted"', max_attempts=MAX_ATTEMPTS)
262-
257+
# https://docs.unity3d.com/hub/manual/InstallHub.html#install-hub-linux
258+
run('sudo sh -c \'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list\'')
259+
run('wget -qO - https://hub.unity3d.com/linux/keys/public | sudo apt-key add -', max_attempts=MAX_ATTEMPTS)
260+
run('sudo apt update')
261+
run('sudo apt-get install unityhub', max_attempts=MAX_ATTEMPTS)
263262

264263
def download_unity_hub(unity_hub_url, unity_hub_installer, max_attempts=1):
265264
attempt_num = 1

0 commit comments

Comments
 (0)