From 7626a5aae3b751cb51d3c56d3fc1b62463372226 Mon Sep 17 00:00:00 2001 From: SimonDarksideJ Date: Thu, 13 Jun 2024 18:24:55 +0100 Subject: [PATCH] Add Unity Hub Running script --- .github/workflows/runHubOnAgent.yml | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/runHubOnAgent.yml diff --git a/.github/workflows/runHubOnAgent.yml b/.github/workflows/runHubOnAgent.yml new file mode 100644 index 0000000..b24ef9a --- /dev/null +++ b/.github/workflows/runHubOnAgent.yml @@ -0,0 +1,73 @@ +name: Run Unity Hub on Agent + +on: + workflow_call: + +jobs: + run_build: + name: Run Unity Build process + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: macos + - os: windows + + steps: + - name: Script Version + run: | + echo "::group::Script Versioning" + $scriptVersion = "1.0.0" + echo "Build Script Version: $scriptVersion" + echo "::endgroup::" + shell: pwsh + - id: openHub + name: 'Run Unity Hub' + run: | + echo "::group::Set Hub and editor locations" + + ## Set Hub and editor locations + if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) + { + $hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe" + $editorRootPath = "C:\Program Files\Unity\Hub\Editor\" + + #"Unity Hub.exe" -- --headless help + #. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help + function unity-hub + { + & $hubPath -- $args.Split(" ") | Out-String -NoNewline + } + } + elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) + { + $hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" + $editorRootPath = "/Applications/Unity/Hub/Editor/" + + # /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help + function unity-hub + { + & $hubPath -- $args.Split(" ") | Out-String -NoNewline + } + } + elseif ( $global:PSVersionTable.OS.Contains("Linux") ) + { + $hubPath = "$HOME/Unity Hub/UnityHub.AppImage" + $editorRootPath = "$HOME/Unity/Hub/Editor/" + + # /UnityHub.AppImage --headless help + # xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help + function unity-hub + { + xvfb-run --auto-servernum "$hubPath" $args.Split(" ") + } + } + echo "::endgroup::" + + echo "::group::StartHub" + $InstalledUnityVersions = unity-hub + echo "::endgroup::" + + exit $LASTEXITCODE + } + shell: pwsh \ No newline at end of file