Skip to content
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
24 changes: 4 additions & 20 deletions .github/workflows/build-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"None",
"4.7.2",
"5.6.7f1 (e80cc3114ac1)",
"2019.4",
"2020",
"2017",
"2018",
"2019.x",
"2020.*",
"2021.3.x",
"2022.x",
"6000.0.x",
Expand Down Expand Up @@ -46,24 +48,6 @@
"os": "macos-latest",
"build-targets": "None",
"modules": "None"
},
{
"os": "ubuntu-latest",
"unity-version": "2019.4.40f1",
"build-targets": "None",
"modules": "None"
},
{
"os": "ubuntu-latest",
"unity-version": "2018.4.36f1 (6cd387d23174)",
"build-targets": "None",
"modules": "None"
},
{
"os": "ubuntu-latest",
"unity-version": "2017.4.40f1 (6e14067f8a9a)",
"build-targets": "None",
"modules": "None"
}
],
"exclude": [
Expand Down
49 changes: 44 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ jobs:
BUILD_OUTPUT_PATH: ${{ github.workspace }}/Builds/${{ matrix.build-target }}
steps:
- name: Free Disk Space
if: ${{ matrix.os == 'ubuntu-latest' && matrix.unity-version == '6000.2' }}
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: endersonmenezes/free-disk-space@v2
with:
remove_android: true
remove_dotnet: false
remove_tool_cache: false
- uses: actions/checkout@v5
- uses: ./ # buildalon/unity-setup
id: unity-setup
with:
version-file: 'None'
unity-version: ${{ matrix.unity-version }}
Expand All @@ -41,10 +42,48 @@ jobs:
auto-update-hub: ${{ !contains(matrix.modules, 'None') }}
hub-version: ${{ contains(matrix.modules, 'None') && '3.12.0' || '' }}
- run: |
echo 'UNITY_HUB_PATH: ${{ env.UNITY_HUB_PATH }}'
echo 'UNITY_EDITORS: ${{ env.UNITY_EDITORS }}'
echo 'UNITY_EDITOR_PATH: ${{ env.UNITY_EDITOR_PATH }}'
echo 'UNITY_PROJECT_PATH: ${{ env.UNITY_PROJECT_PATH }}'
ENV_UNITY_HUB_PATH="${{ env.UNITY_HUB_PATH }}"
echo "env.UNITY_HUB_PATH: \"${ENV_UNITY_HUB_PATH}\""
STEPS_UNITY_HUB_PATH="${{ steps.unity-setup.outputs.unity-hub-path }}"
echo "steps.unity-setup.outputs.unity-hub-path: \"${STEPS_UNITY_HUB_PATH}\""
ENV_UNITY_EDITORS='${{ env.UNITY_EDITORS }}' # single quotes to preserve JSON format and quotes from breaking the script
# The json string is raw and not escaped, which breaks echoing it directly. Escape quotes for safe echoing.
ENV_UNITY_EDITORS="${ENV_UNITY_EDITORS//\"/\\\"}"
echo "env.UNITY_EDITORS: \"${ENV_UNITY_EDITORS}\""
STEPS_UNITY_EDITORS='${{ steps.unity-setup.outputs.unity-editors }}' # single quotes to preserve JSON format and quotes from breaking the script
# The json string is raw and not escaped, which breaks echoing it directly. Escape quotes for safe echoing.
STEPS_UNITY_EDITORS="${STEPS_UNITY_EDITORS//\"/\\\"}"
echo "steps.unity-setup.outputs.unity-editors: \"${STEPS_UNITY_EDITORS}\""
ENV_UNITY_EDITOR_PATH="${{ env.UNITY_EDITOR_PATH }}"
echo "env.UNITY_EDITOR_PATH: \"${ENV_UNITY_EDITOR_PATH}\""
STEPS_UNITY_EDITOR_PATH="${{ steps.unity-setup.outputs.unity-editor-path }}"
echo "steps.unity-setup.outputs.unity-editor-path: \"${STEPS_UNITY_EDITOR_PATH}\""
ENV_UNITY_PROJECT_PATH="${{ env.UNITY_PROJECT_PATH }}"
echo "env.UNITY_PROJECT_PATH: \"${ENV_UNITY_PROJECT_PATH}\""
STEPS_UNITY_PROJECT_PATH="${{ steps.unity-setup.outputs.unity-project-path }}"
echo "steps.unity-setup.outputs.unity-project-path: \"${STEPS_UNITY_PROJECT_PATH}\""

# validate both the env and output variables are the same
if [[ "${ENV_UNITY_HUB_PATH}" != "${STEPS_UNITY_HUB_PATH}" ]]; then
echo "Error: UNITY_HUB_PATH env and output do not match!"
exit 1
fi

if [[ "${ENV_UNITY_EDITORS}" != "${STEPS_UNITY_EDITORS}" ]]; then
echo "Error: UNITY_EDITORS env and output do not match!"
exit 1
fi

if [[ "${ENV_UNITY_EDITOR_PATH}" != "${STEPS_UNITY_EDITOR_PATH}" ]]; then
echo "Error: UNITY_EDITOR_PATH env and output do not match!"
exit 1
fi

if [[ "${ENV_UNITY_PROJECT_PATH}" != "${STEPS_UNITY_PROJECT_PATH}" ]]; then
echo "Error: UNITY_PROJECT_PATH env and output do not match!"
exit 1
fi

# If unity-version is None, UNITY_EDITOR_PATH must be empty
if [[ "${{ matrix.unity-version }}" == "None" ]]; then
if [[ -n "${{ env.UNITY_EDITOR_PATH }}" ]]; then
Expand Down
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ strategy:
modules: mac-server
steps:
- uses: buildalon/unity-setup@v2
id: unity-setup
with:
version-file: 'path/to/your/unity/project/ProjectSettings/ProjectVersion.txt'
unity-version: ${{ matrix.unity-version }} # overrides version in version-file
build-targets: ${{ matrix.build-targets }}
modules: ${{ matrix.modules }}

- run: |
echo "Step Outputs:"
echo "steps.unity-setup.unity-hub-path: '${{ steps.unity-setup.outputs.unity-hub-path }}'"
echo "steps.unity-setup.unity-editors: '${{ steps.unity-setup.outputs.unity-editors }}'"
echo "steps.unity-setup.unity-editor-path: '${{ steps.unity-setup.outputs.unity-editor-path }}'"
echo "steps.unity-setup.unity-project-path: '${{ steps.unity-setup.outputs.unity-project-path }}'"

echo "Environment Variables:"
echo "UNITY_HUB_PATH: '${{ env.UNITY_HUB_PATH }}'"
echo "UNITY_EDITORS: '${{ env.UNITY_EDITORS }}'"
echo "UNITY_EDITOR_PATH: '${{ env.UNITY_EDITOR_PATH }}'"
Expand Down Expand Up @@ -78,7 +86,30 @@ Use any of the following patterns to control how the editor version is resolved:

### outputs

#### step outputs

Steps outputs available for use in subsequent steps:

> [!TIP]
> prefix step outputs with the step id you set in your workflow. In the example above, the step id is `unity-setup`:
>
> `${{ steps.unity-setup.outputs.unity-hub-path }}`

- `unity-hub-path`: The file path to the Unity Hub installation.
- `unity-editors`: A JSON array of all installed Unity Editors on the runner.
- `unity-editor-path`: The path to the latest installed version of Unity.
- `unity-project-path`: The file path to the Unity project.

#### environment variables

Environment variables available for use in subsequent steps:

> [!TIP]
> prefix environment variables with `env.` when using in subsequent steps. For example:
>
> `${{ env.UNITY_HUB_PATH }}`.

- `UNITY_HUB_PATH`: The path to the installed unity hub.
- `UNITY_EDITORS`: A JSON array of all installed Unity Editors on the runner.
- `UNITY_EDITOR_PATH`: The path to the latest installed version of Unity.
- `UNITY_PROJECT_PATH`: The path to the Unity project.
- `UNITY_EDITOR_PATH`: The path to the last installed version of Unity.
- `UNITY_EDITORS`: A json object array of each editor installation `[{"version":"path"},...]`.
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ inputs:
description: 'Specify a specific version of Unity Hub to install. Example: `3.12.0`. When set, auto-update-hub is automatically disabled.'
required: false
default: ''
outputs:
unity-hub-path:
description: 'The file path to the Unity Hub installation.'
unity-editors:
description: 'A JSON array of all installed Unity Editors on the runner.'
unity-editor-path:
description: 'The path to the latest installed version of Unity.'
unity-project-path:
description: 'The file path to the Unity project.'
runs:
using: node20
main: dist/index.js
18 changes: 13 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42172,7 +42172,7 @@ const entToType = (s) => s.isFile() ? IFREG
: s.isFIFO() ? IFIFO
: UNKNOWN;
// normalize unicode path names
const normalizeCache = new Map();
const normalizeCache = new lru_cache_1.LRUCache({ max: 2 ** 12 });
const normalize = (s) => {
const c = normalizeCache.get(s);
if (c)
Expand All @@ -42181,7 +42181,7 @@ const normalize = (s) => {
normalizeCache.set(s, n);
return n;
};
const normalizeNocaseCache = new Map();
const normalizeNocaseCache = new lru_cache_1.LRUCache({ max: 2 ** 12 });
const normalizeNocase = (s) => {
const c = normalizeNocaseCache.get(s);
if (c)
Expand Down Expand Up @@ -42372,6 +42372,7 @@ class PathBase {
get parentPath() {
return (this.parent || this).fullpath();
}
/* c8 ignore start */
/**
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
* this property refers to the *parent* path, not the path object itself.
Expand All @@ -42381,6 +42382,7 @@ class PathBase {
get path() {
return this.parentPath;
}
/* c8 ignore stop */
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
Expand Down Expand Up @@ -59907,7 +59909,7 @@ const entToType = (s) => s.isFile() ? IFREG
: s.isFIFO() ? IFIFO
: UNKNOWN;
// normalize unicode path names
const normalizeCache = new Map();
const normalizeCache = new LRUCache({ max: 2 ** 12 });
const normalize = (s) => {
const c = normalizeCache.get(s);
if (c)
Expand All @@ -59916,7 +59918,7 @@ const normalize = (s) => {
normalizeCache.set(s, n);
return n;
};
const normalizeNocaseCache = new Map();
const normalizeNocaseCache = new LRUCache({ max: 2 ** 12 });
const normalizeNocase = (s) => {
const c = normalizeNocaseCache.get(s);
if (c)
Expand Down Expand Up @@ -60105,6 +60107,7 @@ class PathBase {
get parentPath() {
return (this.parent || this).fullpath();
}
/* c8 ignore start */
/**
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
* this property refers to the *parent* path, not the path object itself.
Expand All @@ -60114,6 +60117,7 @@ class PathBase {
get path() {
return this.parentPath;
}
/* c8 ignore stop */
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
Expand Down Expand Up @@ -63593,6 +63597,7 @@ async function main() {
if (unityProjectPath) {
core.info(`UNITY_PROJECT_PATH:\n > ${unityProjectPath}`);
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
core.setOutput('unity-project-path', unityProjectPath);
}
let autoUpdate = core.getInput('auto-update-hub');
const hubVersion = core.getInput('hub-version');
Expand All @@ -63606,6 +63611,7 @@ async function main() {
}
core.info(`UNITY_HUB_PATH:\n > ${unityHubPath}`);
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
core.setOutput('unity-hub-path', unityHubPath);
if (installPath && installPath.length > 0) {
await unityHub.SetInstallPath(installPath);
}
Expand All @@ -63614,6 +63620,7 @@ async function main() {
const unityEditor = await unityHub.GetEditor(unityVersion, modules);
core.info(`UNITY_EDITOR_PATH:\n > ${unityEditor.editorPath}`);
core.exportVariable('UNITY_EDITOR_PATH', unityEditor.editorPath);
core.setOutput('unity-editor-path', unityEditor.editorPath);
if (modules.includes('android') && unityProjectPath !== undefined) {
await (0, unity_cli_1.CheckAndroidSdkInstalled)(unityEditor, unityProjectPath);
}
Expand All @@ -63622,7 +63629,8 @@ async function main() {
if (installedEditors.length !== versions.length) {
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${installedEditors.length}.`);
}
core.exportVariable('UNITY_EDITORS', Object.fromEntries(installedEditors.map(e => [e.version, e.path])));
core.exportVariable('UNITY_EDITORS', JSON.stringify(installedEditors));
core.setOutput('unity-editors', JSON.stringify(installedEditors));
core.info('Unity Setup Complete!');
process.exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "2.1.2",
"version": "2.2.0",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "Buildalon",
"license": "MIT",
Expand Down Expand Up @@ -32,7 +32,7 @@
"yaml": "^2.8.1"
},
"devDependencies": {
"@types/node": "^22.18.13",
"@types/node": "^22.19.1",
"@types/semver": "^7.7.1",
"@vercel/ncc": "^0.34.0",
"shx": "^0.4.0",
Expand Down
Loading
Loading