Skip to content

Commit

Permalink
Install unity in script and remove kuler90/setup-unity@v1 (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunmou99 authored Nov 29, 2022
1 parent 02a3372 commit 8c53096
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 183 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ jobs:
ref: ${{ inputs.firebase_cpp_sdk_version }}
submodules: true

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Setup python
uses: actions/setup-python@v4
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ jobs:
submodules: true
ref: ${{ inputs.firebase_cpp_sdk_version }}

# Set up the requirements, and install Unity
# Ruby setup has to happen before python install and setup, to keep the absl config.
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2

- name: Setup python
uses: actions/setup-python@v4
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ jobs:
submodules: true
ref: ${{ inputs.firebase_cpp_sdk_version }}

# Set up the requirements, and install Unity
# Ruby setup has to happen before python install and setup, to keep the absl config.
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2

# Remove other python installs before installing the version we want
- name: Remove other pythons
shell: bash
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ jobs:
- name: Support longpaths
run: git config --system core.longpaths true

# Set up the requirements, and install Unity
# Ruby setup has to happen before python install and setup, to keep the absl config.
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2

- name: Setup python
uses: actions/setup-python@v4
with:
Expand Down
62 changes: 35 additions & 27 deletions gha/unity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
## Inputs
- `version`: **[Required]** Unity Major Version Number. Currently supported values: [2019, 2020].

- `platforms`: Platforms that you'd like to support, if not provided, some platforms may encounter errors. Values: [Android,iOS,tvOS,Windows,macOS,Linux].
- `platforms`: Platforms that you'd like to support, if not provided, build apps on certain platforms may encounter errors. Values: [Android,iOS,tvOS,Windows,macOS,Linux].

- `username`: Required when Activate Unity license. Refer to the Usage section below.
- `username`: Required when Activate Unity license. See the [Usage](https://github.com/firebase/firebase-unity-sdk/tree/main/gha/unity#usage) section below.

- `password`: Required when Activate Unity license. Refer to the Usage section below.
- `password`: Required when Activate Unity license. See the Usage section below.

- `serial_ids`: Required when Activate Unity license. Refer to the Usage section below.
- `serial_ids`: Required when Activate Unity license. See the Usage section below.

- `release_license`: If a license has been activated in the pervious step, then **must** add anothe step and set **"ture"** to `release_license` input.
- `release_license`: If a license has been activated in the pervious step, then **must** add another step to release the license. Set **"ture"** to `release_license` input.

## Output

This GitHub Action will provide `UNITY_VERSION` (full unity version) and `UNITY_ROOT_DIR` (Unity project directory) environment variable
This GitHub Action will provide `UNITY_VERSION` (full unity version, e.g. `2020.3.34f1`) and `UNITY_ROOT_DIR` (Unity project directory, e.g. `/Applications/Unity/Hub/Editor/2020.3.34f1`) environment variables as outputs.

- Output usage:
```yml
- id: unity_setup
uses: firebase/firebase-unity-sdk/gha/unity@main
- uses: firebase/firebase-unity-sdk/gha/unity@main
with:
version: ${{ unity_version }}
platforms: ${{ platforms }}
Expand All @@ -38,8 +37,7 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version) and `UNITY_

steps:
# ...
- id: unity_setup
uses: firebase/firebase-unity-sdk/gha/unity@main
- uses: firebase/firebase-unity-sdk/gha/unity@main
with:
version: ${{ unity_version }}
platforms: ${{ platforms }}
Expand All @@ -53,7 +51,7 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version) and `UNITY_

steps:
# ...
- id: unity_setup
- id: unity_setup_and_activate
uses: firebase/firebase-unity-sdk/gha/unity@main
with:
version: ${{ unity_version }}
Expand All @@ -69,29 +67,45 @@ This GitHub Action will provide `UNITY_VERSION` (full unity version) and `UNITY_
release_license: "true"
```
## [Deprecated] How to upgrade supported unity versions
## How to upgrade supported unity versions
**Background**
This GitHub Action leverages [U3D](github.com/DragonBox/u3d), which is a command line tool for working with Unity from the command line on all three operating systems.
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.
In this GitHub Action, supported Unity Versions are maintained by `UNITY_SETTINGS` in `gha/unity/unity_installer.py`.
In this GitHub Action, supported Unity Versions are maintained by `SETTINGS` in `gha/unity/unity_installer.py`.

**Add a new Unity version support**

1. Install [U3D](github.com/DragonBox/u3d).
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.

2. Generate new JSON string and added it to `UNITY_SETTINGS`:
- `Major_version_number`: unity major version number: 2020, 2021, etc.
- `Full_version_number`: unity full version number. e.g. 2020.3.34f1 for major version 2020. Run `u3d available` and select [Unity LTS versions](https://unity3d.com/unity/qa/lts-releases).
- `Platform`: Values of [Android,iOS,tvOS,Windows,macOS,Linux]
- `Package`:[Unity Hub must **not** been installed] Unity Packages that required for certain platform. e.g. ["Windows-mono"] pakcages for "Windows" platform. To list avaliable packages, run `u3d available -u $unity_version -p`.
- `Major_version_number`: unity major version number: `2020`, `2021`, etc.
- `Full_version_number`: unity full version number. e.g. `2020.3.34f1` for major version `2020`.
- `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
- `Platform`: Firebase Unity SDK supported platforms. Values of [Android,iOS,tvOS,Windows,macOS,Linux]
- `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.

Template:
```
UNITY_SETTINGS = {
Major_version_number: {
OS: {
"version": Full_version_number,
"packages": {Platform: [Package], ...},
"changeset": Changeset,
"modules": {Platform: [Moudles], ...},
},
...
},
}
```
e.g.
```
UNITY_SETTINGS = {
"2020": {
WINDOWS: {
"version": "2020.3.34f1",
"changeset": "9a4c9c70452b",
"modules": {ANDROID: ["android", "ios"], IOS: ["ios"], TVOS: ["appletv"], WINDOWS: [], MACOS: ["mac-mono"], LINUX: ["linux-mono"], PLAYMODE: ["ios"]},
},
...
},
Expand All @@ -100,10 +114,4 @@ In this GitHub Action, supported Unity Versions are maintained by `UNITY_SETTING

**Common failures & solutions**

1. If you met problem with `u3d` cmd (e.g. `u3d available -u $unity_version -p`), please install older version of `u3d` and disable the `u3d` version check. Then try it again.
```
gem install u3d -v 1.2.3
export U3D_SKIP_UPDATE_CHECK=1
```

2. If you have problem with Android build. Make sure you are using the right version of NDK and JDK. Testapp building process is using a patch function `patch_android_env` in `build_testapp.py`. (Please refer [Unity Documentation](https://docs.unity3d.com/Manual/android-sdksetup.html) for Android environment setup).
1. If you have problem with Android build. Make sure you are using the right version of NDK and JDK. Testapp building process is using a patch function `patch_android_env` in `build_testapp.py`. (Please refer [Unity Documentation](https://docs.unity3d.com/Manual/android-sdksetup.html) for Android environment setup).
33 changes: 17 additions & 16 deletions gha/unity/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ inputs:
runs:
using: 'composite'
steps:
- id: configs
shell: bash
run: |
if [[ "${{ inputs.release_license }}" != "" ]]; then
echo "release_license=True" >> $GITHUB_OUTPUT
else
echo "install_unity=True" >> $GITHUB_OUTPUT
if [[ "${{ inputs.username }}" != "" && "${{ inputs.password }}" != "" && "${{ inputs.serial_ids }}" != "" ]]; then
echo "activate_license=True" >> $GITHUB_OUTPUT
fi
fi
- name: Return Unity license
if: inputs.release_license
if: steps.configs.outputs.release_license
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
Expand All @@ -42,28 +53,18 @@ runs:
--version ${{ inputs.version }} \
--logfile "testapps/release_license.log"
cat testapps/release_license.log
- name: unity_setting
if: inputs.release_license == ''
shell: bash
run: |
unity_info=$( python $GITHUB_ACTION_PATH/unity_installer.py --setting --version ${{ inputs.version }})
echo "UNITY_VERSION=$(cut -d',' -f1 <<< ${unity_info})" >> $GITHUB_ENV
echo "UNITY_ROOT_DIR=$(cut -d',' -f2 <<< ${unity_info})" >> $GITHUB_ENV
- name: Install Unity
if: inputs.release_license == ''
uses: kuler90/setup-unity@v1
with:
unity-version: ${{ env.UNITY_VERSION }}
- name: Install Unity Modules
if: inputs.release_license == ''
if: steps.configs.outputs.install_unity
shell: bash
run: |
if [[ -n "${{ inputs.platforms }}" ]]; then
additional_flags+=(--platforms ${{ inputs.platforms }})
fi
python $GITHUB_ACTION_PATH/unity_installer.py --install_modules --version ${{ inputs.version }} ${additional_flags[*]}
unity_info=$(python $GITHUB_ACTION_PATH/unity_installer.py --install --version ${{ inputs.version }} ${additional_flags[*]})
echo "UNITY_VERSION=$(cut -d',' -f1 <<< ${unity_info})" >> $GITHUB_ENV
echo "UNITY_ROOT_DIR=$(cut -d',' -f2 <<< ${unity_info})" >> $GITHUB_ENV
- name: Activate Unity license
if: inputs.release_license == '' && inputs.username != '' && inputs.password != '' && inputs.serial_ids != ''
if: steps.configs.outputs.activate_license
shell: bash
run: |
python $GITHUB_ACTION_PATH/unity_installer.py --activate_license \
Expand Down
Loading

0 comments on commit 8c53096

Please sign in to comment.