Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] #7

Merged
merged 12 commits into from
Aug 10, 2024
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
9 changes: 2 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
unity-versions:
- 'in version file'
- 'None'
- 2019.4.40f1 (ffc62b691db5)
- 2020.3.48f1 (b805b124c6b7)
- 2021.3.41f1 (6c5a9e20c022)
Expand All @@ -47,15 +47,10 @@ jobs:
modules: mac-server
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: RageAgainstThePixel/com.utilities.buildpipeine
path: com.utilities.buildpipline
ref: development

- uses: ./ # buildalon/unity-setup
with:
version-file: com.utilities.buildpipline/Utilities.BuildPipeline/ProjectSettings/ProjectVersion.txt
version-file: 'None'
unity-version: ${{ matrix.unity-versions }}
build-targets: ${{ matrix.build-targets }}
modules: ${{ matrix.modules }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ steps:

| name | description | required |
| ----------- | ----------- | ----------- |
| `version-file` | Specify a path to search for the unity project version text file. Useful if there are multiple projects in a single repo. | false |
| `version-file` | Specify a path to search for the unity project version text file. Useful if there are multiple projects in a single repo. Pass `None` if creating a new project to skip file search. | false |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on this description I don't understand when I would use 'None'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating a new project or skipping the file search option.

| `unity-version` | Specify the Unity version(s) to install. You must include the changeset! i.e `2019.4.13f1 (518737b1de84)`. ***This will override any version specified in the `version-file`!*** | false |
| `build-targets` | Specify the build targets to install for. Remaps to corresponding module. One or more of `StandaloneWindows64` `WSAPlayer` `StandaloneOSX` `iOS` `StandaloneLinux64` `Android` `Lumin` `WebGL` `VisionOS`. | false |
| `modules` | Modules to install with the editor. This list can be different per editor version. | false |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ branding:
icon: download
inputs:
version-file:
description: 'Specify a path to search for the unity project version text file. Useful if there are multiple projects in a single repo.'
description: 'Specify a path to search for the unity project version text file. Useful if there are multiple projects in a single repo. Pass `None` if creating a new project to skip file search.'
required: false
default: ''
unity-version:
Expand Down
53 changes: 31 additions & 22 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34259,20 +34259,22 @@ async function ValidateInputs() {
if (modules.length == 0) {
throw Error('No modules or build-targets provided!');
}
const versionFilePath = await getVersionFilePath();
core.info(`versionFilePath:\n > "${versionFilePath}"`);
const [unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
const versions = getUnityVersionsFromInput();
if (versions.length === 0) {
versions.push([unityVersion, changeset]);
const versionFilePath = await getVersionFilePath();
const unityProjectPath = versionFilePath !== undefined ? path.join(versionFilePath, '..', '..') : undefined;
if (versionFilePath) {
core.info(`versionFilePath:\n > "${versionFilePath}"`);
core.info(`Unity Project Path:\n > "${unityProjectPath}"`);
const [unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
if (versions.length === 0) {
versions.push([unityVersion, changeset]);
}
}
versions.sort(([a], [b]) => semver.compare(a, b, true));
core.info(`Unity Versions:`);
for (const [version, changeset] of versions) {
core.info(` > ${version} (${changeset})`);
}
const unityProjectPath = path.join(versionFilePath, '..', '..');
core.info(`Unity Project Path:\n > "${unityProjectPath}"`);
return [versions, architecture, modules, unityProjectPath];
}

Expand Down Expand Up @@ -34351,31 +34353,36 @@ function getDefaultModules() {

async function getVersionFilePath() {
let projectVersionPath = core.getInput('version-file');
if (projectVersionPath) {
} else {
if (projectVersionPath !== undefined && projectVersionPath.toLowerCase() === 'none') {
return undefined;
}
if (!projectVersionPath) {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
}
try {
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
if (projectVersionPath) {
try {
projectVersionPath = path.join(process.env.GITHUB_WORKSPACE, projectVersionPath);
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.error(error);
core.debug(error);
try {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
projectVersionPath = path.join(process.env.GITHUB_WORKSPACE, projectVersionPath);
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
core.error(error);
try {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
// ignore
}
}
}
throw Error(`Could not find ProjectVersion.txt in ${projectVersionPath}`);
}
core.warning(`Could not find ProjectVersion.txt in ${process.env.GITHUB_WORKSPACE}! UNITY_PROJECT_PATH will not be set.`);
return undefined;
}

function getUnityVersionsFromInput() {
Expand Down Expand Up @@ -34723,7 +34730,7 @@ async function execUnityHub(args) {
});
break;
case 'linux': // xvfb-run --auto-servernum "~/Unity Hub/UnityHub.AppImage" --headless help
core.info(`[command]"xvfb-run" --auto-servernum "${hubPath}" --headless ${args.join(' ')}`);
core.info(`[command]xvfb-run --auto-servernum "${hubPath}" --headless ${args.join(' ')}`);
await exec.exec('xvfb-run', ['--auto-servernum', hubPath, '--headless', ...args], {
listeners: {
stdline: (data) => {
Expand Down Expand Up @@ -45386,15 +45393,17 @@ const core = __nccwpck_require__(2186);
const main = async () => {
try {
const [versions, architecture, modules, unityProjectPath] = await ValidateInputs();
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
if (unityProjectPath) {
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
}
const unityHubPath = await unityHub.Get();
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
const editors = [];
for (const [version, changeset] of versions) {
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);
// for now just export the highest installed version
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath);
if (modules.includes('android')) {
if (modules.includes('android') && unityProjectPath !== undefined) {
await CheckAndroidSdkInstalled(unityEditorPath, unityProjectPath);
}
editors.push([version, unityEditorPath]);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dist/install-unityhub-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Write-Host "Downloading `"$url`" > `"$tempPath`"..."
$wc.DownloadFile($url, $tempPath)
Write-Host "`"$tempPath`" /S"
$process = Start-Process -FilePath $tempPath -ArgumentList '/S' -PassThru -Wait
Write-Host "Unity Hub installation completed with exit code $process.ExitCode"
Write-Host "::endgroup::"
exit $process.ExitCode
exit [int]$process.ExitCode
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": "1.0.5",
"version": "1.0.6",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "Buildalon",
"license": "MIT",
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ const core = require('@actions/core');
const main = async () => {
try {
const [versions, architecture, modules, unityProjectPath] = await ValidateInputs();
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
if (unityProjectPath) {
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
}
const unityHubPath = await unityHub.Get();
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
const editors = [];
for (const [version, changeset] of versions) {
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);
// for now just export the highest installed version
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath);
if (modules.includes('android')) {
if (modules.includes('android') && unityProjectPath !== undefined) {
await CheckAndroidSdkInstalled(unityEditorPath, unityProjectPath);
}
editors.push([version, unityEditorPath]);
Expand Down
45 changes: 26 additions & 19 deletions src/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ async function ValidateInputs() {
if (modules.length == 0) {
throw Error('No modules or build-targets provided!');
}
const versionFilePath = await getVersionFilePath();
core.info(`versionFilePath:\n > "${versionFilePath}"`);
const [unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
const versions = getUnityVersionsFromInput();
if (versions.length === 0) {
versions.push([unityVersion, changeset]);
const versionFilePath = await getVersionFilePath();
const unityProjectPath = versionFilePath !== undefined ? path.join(versionFilePath, '..', '..') : undefined;
if (versionFilePath) {
core.info(`versionFilePath:\n > "${versionFilePath}"`);
core.info(`Unity Project Path:\n > "${unityProjectPath}"`);
const [unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
if (versions.length === 0) {
versions.push([unityVersion, changeset]);
}
}
versions.sort(([a], [b]) => semver.compare(a, b, true));
core.info(`Unity Versions:`);
for (const [version, changeset] of versions) {
core.info(` > ${version} (${changeset})`);
}
const unityProjectPath = path.join(versionFilePath, '..', '..');
core.info(`Unity Project Path:\n > "${unityProjectPath}"`);
return [versions, architecture, modules, unityProjectPath];
}

Expand Down Expand Up @@ -134,31 +136,36 @@ function getDefaultModules() {

async function getVersionFilePath() {
let projectVersionPath = core.getInput('version-file');
if (projectVersionPath) {
} else {
if (projectVersionPath !== undefined && projectVersionPath.toLowerCase() === 'none') {
return undefined;
}
if (!projectVersionPath) {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
}
try {
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
if (projectVersionPath) {
try {
projectVersionPath = path.join(process.env.GITHUB_WORKSPACE, projectVersionPath);
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.error(error);
core.debug(error);
try {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
projectVersionPath = path.join(process.env.GITHUB_WORKSPACE, projectVersionPath);
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
core.error(error);
try {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
// ignore
}
}
}
throw Error(`Could not find ProjectVersion.txt in ${projectVersionPath}`);
}
core.warning(`Could not find ProjectVersion.txt in ${process.env.GITHUB_WORKSPACE}! UNITY_PROJECT_PATH will not be set.`);
return undefined;
}

function getUnityVersionsFromInput() {
Expand Down
3 changes: 1 addition & 2 deletions src/install-unityhub-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Write-Host "Downloading `"$url`" > `"$tempPath`"..."
$wc.DownloadFile($url, $tempPath)
Write-Host "`"$tempPath`" /S"
$process = Start-Process -FilePath $tempPath -ArgumentList '/S' -PassThru -Wait
Write-Host "Unity Hub installation completed with exit code $process.ExitCode"
Write-Host "::endgroup::"
exit $process.ExitCode
exit [int]$process.ExitCode
2 changes: 1 addition & 1 deletion src/unity-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async function execUnityHub(args) {
});
break;
case 'linux': // xvfb-run --auto-servernum "~/Unity Hub/UnityHub.AppImage" --headless help
core.info(`[command]"xvfb-run" --auto-servernum "${hubPath}" --headless ${args.join(' ')}`);
core.info(`[command]xvfb-run --auto-servernum "${hubPath}" --headless ${args.join(' ')}`);
await exec.exec('xvfb-run', ['--auto-servernum', hubPath, '--headless', ...args], {
listeners: {
stdline: (data) => {
Expand Down