Skip to content
This repository was archived by the owner on Aug 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
include:
- os: ubuntu-latest
build-targets: 'StandaloneLinux64 Android iOS'
- os: windows-latest
build-targets: 'StandaloneWindows64 Android iOS'
- os: macos-latest
build-targets: 'StandaloneOSX Android iOS'

steps:
- name: checkout self
Expand All @@ -33,9 +39,10 @@ jobs:
repository: xrtk/com.xrtk.test
path: test-project

- uses: ./
- uses: ./ # xrtk/unity-setup
id: unity-setup
with:
version-file-path: 'test-project/**/ProjectSettings/ProjectVersion.txt'
build-targets: '${{ matrix.build-targets }}'

- run: |
echo "${{ env.UNITY_EDITOR_PATH }}"
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ Part of the [Mixed Reality Toolkit (XRTK)](https://github.com/XRTK) open source
jobs:
setup-unity:
strategy:
fail-fast: false
runs-on: ${{ matrix.os }}
strategy:
matrix:
runner: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.runner }}
include:
- os: ubuntu-latest
build-targets: 'StandaloneLinux64 Android iOS'
- os: windows-latest
build-targets: 'StandaloneWindows64 Android iOS'
- os: macos-latest
build-targets: 'StandaloneOSX Android iOS'

steps:
- uses: actions/checkout@v3

- id: unity-setup
uses: xrtk/unity-setup@v4
with:
modules: 'android ios' #Optional, overrides the default platform specific module installs.
#version-file-path: '**/ProjectSettings/ProjectVersion.txt' # Optional
uses: xrtk/unity-setup@v5
with:
modules: '${{ matrix.build-targets }}' #Optional, overrides the default platform specific module installs.
#version-file-path: 'ProjectSettings/ProjectVersion.txt' # Optional

- run: |
echo "${{ env.UNITY_EDITOR_PATH }}"
Expand Down
18 changes: 9 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: 'Unity Setup'
description: 'Installs the Unity Editor and modules based on the build target and project settings.'
inputs:
version-file-path:
description: 'Optional, specify a path to search for the unity project version text file. Use this if step fails to find a valid project version file.'
required: false
default: ''
build-targets:
description: 'Optional, specify the build targets to install for (i.e "StandaloneWindows64 WSAPlayer StandaloneOSX iOS StandaloneLinux64 Android Lumin WebGL")'
required: false
default: ''
modules:
deprecationMessage: 'Use build-targets instead'
description: 'Optional, Additional modules to install with the editor (i.e "webgl android lumin")'
required: false
default: ''
version-file-path:
description: 'Optional, specify a path to search for the unity project version text file. Use this if step fails to find a valid project version file.'
required: false
default: '**/ProjectSettings/ProjectVersion.txt'
outputs:
editor-path:
description: 'The path to the Unity Editor'
project-path:
description: 'The path to the unity project'
runs:
using: 'node16'
main: 'dist/index.js'
119 changes: 116 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3995,6 +3995,14 @@ module.exports = require("fs");

/***/ }),

/***/ 292:
/***/ ((module) => {

"use strict";
module.exports = require("fs/promises");

/***/ }),

/***/ 685:
/***/ ((module) => {

Expand Down Expand Up @@ -4112,19 +4120,92 @@ const core = __nccwpck_require__(186);
const exec = __nccwpck_require__(514);
const io = __nccwpck_require__(436);
const path = __nccwpck_require__(17);
const fs = __nccwpck_require__(147);
const { readdir } = __nccwpck_require__(292);
const os = __nccwpck_require__(37);

const main = async () => {
try {
var modules = core.getInput('modules');
var modules = '';
var buildTargets = core.getInput('build-targets');
core.debug(`buildTargets: ${buildTargets}`);

if (!buildTargets) {
modules = core.getInput('modules');
core.debug(`modules: ${modules}`);
} else {
var moduleMap = undefined;

const osType = os.type();
if (osType == 'Linux') {
moduleMap = {
"StandaloneLinux64": "linux-il2cpp",
"Android": "android",
"WebGL": "webgl",
"iOS": "ios",
};
} else if (osType == 'Darwin') {
moduleMap = {
"StandaloneOSX": "mac-il2cpp",
"iOS": "ios",
"Android": "android",
"tvOS": "appletv",
"StandaloneLinux64": "linux-il2cpp",
};
} else if (osType == 'Windows_NT') {
moduleMap = {
"StandaloneWindows64": "windows-il2cpp",
"WSAPlayer": "universal-windows-platform",
"Android": "android",
"iOS": "ios",
"tvOS": "appletv",
"StandaloneLinux64": "linux-il2cpp",
"Lumin": "lumin",
"WebGL": "webgl",
};
} else {
throw Error(`${osType} not supported`);
}

var targets = buildTargets.split(' ');
core.debug(`targets: ${targets}`);

for (const target of targets) {
core.debug(`target: ${target}`);

var module = moduleMap[target];

if (module === undefined) {
core.warning(`${target} not a valid build-target`);
continue;
}

modules += `${module} `;
core.debug(` ${target} -> ${module}`);
}

modules = modules.trim();
}

var versionFilePath = core.getInput('version-file-path');

if (!versionFilePath) {
// search for license file version
var exeDir = path.resolve(process.cwd());
core.debug(`exeDir: ${exeDir}`);
versionFilePath = await findFile(exeDir, 'ProjectVersion.txt');
core.debug(`version file path: ${versionFilePath}`);
}

core.debug(`modules: ${modules}`);
core.debug(`versionFilePath: ${versionFilePath}`);

var args = `-modulesList \"${modules}\" -versionFilePath \"${versionFilePath}\"`;
var pwsh = await io.which("pwsh", true);
var install = __nccwpck_require__.ab + "unity-install.ps1";
var exitCode = 0;

console.log(`::group::Run xrtk/unity-setup`);
exitCode = await exec.exec(`"${pwsh}" -Command`, `${install} ${args}`);
console.log(`::endgroup::`);

if (exitCode != 0) {
throw Error(`Unity Installation Failed! exitCode: ${exitCode}`)
Expand All @@ -4134,6 +4215,38 @@ const main = async () => {
}
}

const findFile = async (dir, filePath) => {
const directories = [];
const matchedFiles = [];
const files = await readdir(dir);

for (const file of files) {
const item = path.resolve(dir, file);

if (fs.statSync(`${dir}/${file}`).isDirectory()) {
directories.push(item);
} else if (file.endsWith(filePath)) {
core.debug(`--> Found! ${item}`);
matchedFiles.push(item);
break;
}
}

if (matchedFiles.length == 0) {
for(const subDir of directories) {
const nestedMatches = await findFile(subDir, filePath);

for (const nestedMatch of nestedMatches) {
matchedFiles.push(nestedMatch);
break;
}
}
}

return matchedFiles;
};


// Call the main function to run the action
main();
})();
Expand Down
27 changes: 27 additions & 0 deletions dist/unity-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,33 @@ if ( -not (Test-Path -Path $editorPath)) {

$installArgsString = $installArgs -join " "

Write-Host "::group::Run unity-hub $installArgsString"
Invoke-UnityHub $installArgsString
Write-Host ""
Write-Host "::endgroup::"
} else {
Write-Host "Intalling modules for $unityVersion ($unityVersionChangeSet)"
$installArgs = @('install-modules',"--version $unityVersion",'--cm')

$addModules = @()

foreach ($module in $modules) {
if ($module -eq 'android') {
$addmodules += 'android-open-jdk'
$addmodules += 'android-sdk-ndk-tools'
}
}

$modules += $addModules

foreach ($module in $modules) {
$installArgs += '-m'
$installArgs += $module
Write-Host " > with module: $module"
}

$installArgsString = $installArgs -join " "

Write-Host "::group::Run unity-hub $installArgsString"
Invoke-UnityHub $installArgsString
Write-Host ""
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "4.0.0",
"version": "5.0.0",
"description": "An atomic GitHub action to download and install the Unity Editor for runners.",
"main": "src/index.js",
"scripts": {
Expand Down
Loading