11name : unity-build
2- permissions :
3- contents : read
42on :
53 workflow_call :
64 inputs :
1513jobs :
1614 build :
1715 name : ${{ matrix.name }}
16+ runs-on : ${{ matrix.os }}
1817 strategy :
1918 matrix : ${{ fromJSON(inputs.matrix) }}
2019 fail-fast : false
21- runs-on : ${{ matrix.os }}
22- permissions :
23- contents : read
20+ defaults :
21+ run :
22+ shell : bash
2423 env :
25- UNITY_PROJECT_PATH : ' ' # Set from create-project step
24+ UNITY_PROJECT_PATH : ' ' # Create Unity Project step will set this if needed
2625 steps :
2726 - name : Free Disk Space
2827 if : ${{ matrix.os == 'ubuntu-latest' && (matrix.unity-version != '2018' && matrix.unity-version != '2017.4.40f1') }}
29- uses : endersonmenezes/free-disk-space@713d134e243b926eba4a5cce0cf608bfd1efb89a # v2 .1.1
28+ uses : endersonmenezes/free-disk-space@e6ed9b02e683a3b55ed0252f1ee469ce3b39a885 # v3 .1.0
3029 with :
3130 remove_android : true
3231 remove_dotnet : false
3332 remove_tool_cache : false
34- - uses : actions/checkout@v5
33+ - uses : actions/checkout@v6
3534 - uses : actions/setup-node@v6
3635 with :
3736 node-version : 24.x
3837 - name : Setup unity-cli
39- shell : bash
4038 run : |
4139 npm ci
4240 npm run build
4341 npm run link
4442 unity-cli --version
4543 - name : Setup Unity
46- shell : bash
4744 timeout-minutes : 30
4845 run : |
4946 unity-cli hub-install --hub-version 3.12.0
5350 unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-target }}" --json
5451 fi
5552 - name : Verify UNITY_HUB_PATH and UNITY_EDITOR_PATH variables
56- shell : bash
5753 run : |
5854 echo "UNITY_HUB_PATH: ${UNITY_HUB_PATH}"
5955 echo "UNITY_EDITOR_PATH: ${UNITY_EDITOR_PATH}"
@@ -70,20 +66,17 @@ jobs:
7066 fi
7167 - name : Activate License
7268 if : ${{ matrix.unity-version != 'none' }}
73- shell : bash
7469 run : |
7570 unity-cli license-context
7671 unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
7772 - name : Create Unity Project
7873 if : ${{ matrix.unity-version != 'none' }}
79- shell : bash
8074 run : |
8175 unity-cli list-project-templates --unity-editor "${UNITY_EDITOR_PATH}" --json
8276 unity-cli create-project --name "Unity Project" --unity-editor "${UNITY_EDITOR_PATH}" --json
8377 - name : Verify UNITY_PROJECT_PATH variable
8478 if : ${{ matrix.unity-version != 'none' }}
8579 id : verify-project-path
86- shell : bash
8780 run : |
8881 if [ -z "${UNITY_PROJECT_PATH}" ]; then
8982 echo "::error::UNITY_PROJECT_PATH is not set"
@@ -105,15 +98,13 @@ jobs:
10598 echo "Skipping build: Unity version $version does not support the build pipeline package (requires 2019.4+)"
10699 fi
107100 - name : Install OpenUPM and build pipeline package
108- shell : bash
109101 if : ${{ steps.verify-project-path.outputs.RUN_BUILD == 'true' }}
102+ working-directory : ${{ env.UNITY_PROJECT_PATH }}
110103 run : |
111104 npm install -g openupm-cli
112- cd "${UNITY_PROJECT_PATH}"
113105 openupm add com.utilities.buildpipeline
114106 - name : Update Android Target Sdk Version
115107 if : ${{ matrix.build-target == 'Android' }}
116- shell : bash
117108 run : |
118109 # update AndroidTargetSdkVersion to 32 in ProjectSettings/ProjectSettings.asset
119110 sed -i 's/AndroidTargetSdkVersion: [0-9]*/AndroidTargetSdkVersion: 32/' "${UNITY_PROJECT_PATH}/ProjectSettings/ProjectSettings.asset"
@@ -122,13 +113,12 @@ jobs:
122113 - name : Build Project
123114 if : ${{ steps.verify-project-path.outputs.RUN_BUILD == 'true' }}
124115 timeout-minutes : 60
125- shell : bash
126116 run : |
117+ # we don't have to specify the project path or unity editor path as unity-cli will use the environment variables
127118 unity-cli run --log-name Validate -quit -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset
128119 unity-cli run --log-name Build -buildTarget ${{ matrix.build-target }} -quit -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity ${{ matrix.build-args }}
129120 - name : Uninstall Editor
130121 if : ${{ matrix.unity-version != 'none' }}
131- shell : bash
132122 run : |
133123 if [ -z "${UNITY_EDITOR_PATH}" ]; then
134124 echo "UNITY_EDITOR_PATH is not set, skipping uninstall"
@@ -137,7 +127,6 @@ jobs:
137127 unity-cli uninstall-unity --unity-editor "${UNITY_EDITOR_PATH}"
138128 - name : Print log paths
139129 if : ${{ matrix.unity-version != 'none' }}
140- shell : bash
141130 run : |
142131 HUB_LOG_PATH=$(unity-cli hub-logs)
143132 PACKAGE_MANAGER_LOG_PATH=$(unity-cli package-manager-logs)
@@ -160,11 +149,11 @@ jobs:
160149 fi
161150 # print all files found in ~/.config/
162151 find ~/.config/ -type f -exec echo "{}" \;
163- echo "::error :: Hub log file does not exist at any known location"
152+ echo "::warning :: Hub log file does not exist at any known location"
164153 fi
165154
166155 if [ ! -f "${PACKAGE_MANAGER_LOG_PATH}" ]; then
167- echo "::error ::Package Manager log file does not exist at ${PACKAGE_MANAGER_LOG_PATH}"
156+ echo "::warning ::Package Manager log file does not exist at ${PACKAGE_MANAGER_LOG_PATH}"
168157 fi
169158
170159 if [ ! -f "${LICENSING_CLIENT_LOG_PATH}" ]; then
@@ -176,6 +165,4 @@ jobs:
176165 fi
177166 - name : Return License
178167 if : always()
179- shell : bash
180- run : |
181- unity-cli return-license --license personal
168+ run : unity-cli return-license --license personal
0 commit comments