Skip to content

Commit de89762

Browse files
unity-setup@v2.2.0 (#44)
- adds `steps.[id].outputs` - `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 file path to the primary Unity Editor installation - `unity-project-path`: The file path to the Unity project
1 parent 62de736 commit de89762

File tree

9 files changed

+129
-52
lines changed

9 files changed

+129
-52
lines changed

.github/workflows/build-options.json

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
"None",
99
"4.7.2",
1010
"5.6.7f1 (e80cc3114ac1)",
11-
"2019.4",
12-
"2020",
11+
"2017",
12+
"2018",
13+
"2019.x",
14+
"2020.*",
1315
"2021.3.x",
1416
"2022.x",
1517
"6000.0.x",
@@ -46,24 +48,6 @@
4648
"os": "macos-latest",
4749
"build-targets": "None",
4850
"modules": "None"
49-
},
50-
{
51-
"os": "ubuntu-latest",
52-
"unity-version": "2019.4.40f1",
53-
"build-targets": "None",
54-
"modules": "None"
55-
},
56-
{
57-
"os": "ubuntu-latest",
58-
"unity-version": "2018.4.36f1 (6cd387d23174)",
59-
"build-targets": "None",
60-
"modules": "None"
61-
},
62-
{
63-
"os": "ubuntu-latest",
64-
"unity-version": "2017.4.40f1 (6e14067f8a9a)",
65-
"build-targets": "None",
66-
"modules": "None"
6751
}
6852
],
6953
"exclude": [

.github/workflows/build.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ jobs:
2525
BUILD_OUTPUT_PATH: ${{ github.workspace }}/Builds/${{ matrix.build-target }}
2626
steps:
2727
- name: Free Disk Space
28-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.unity-version == '6000.2' }}
28+
if: ${{ matrix.os == 'ubuntu-latest' }}
2929
uses: endersonmenezes/free-disk-space@v2
3030
with:
3131
remove_android: true
3232
remove_dotnet: false
3333
remove_tool_cache: false
3434
- uses: actions/checkout@v5
3535
- uses: ./ # buildalon/unity-setup
36+
id: unity-setup
3637
with:
3738
version-file: 'None'
3839
unity-version: ${{ matrix.unity-version }}
@@ -41,10 +42,48 @@ jobs:
4142
auto-update-hub: ${{ !contains(matrix.modules, 'None') }}
4243
hub-version: ${{ contains(matrix.modules, 'None') && '3.12.0' || '' }}
4344
- run: |
44-
echo 'UNITY_HUB_PATH: ${{ env.UNITY_HUB_PATH }}'
45-
echo 'UNITY_EDITORS: ${{ env.UNITY_EDITORS }}'
46-
echo 'UNITY_EDITOR_PATH: ${{ env.UNITY_EDITOR_PATH }}'
47-
echo 'UNITY_PROJECT_PATH: ${{ env.UNITY_PROJECT_PATH }}'
45+
ENV_UNITY_HUB_PATH="${{ env.UNITY_HUB_PATH }}"
46+
echo "env.UNITY_HUB_PATH: \"${ENV_UNITY_HUB_PATH}\""
47+
STEPS_UNITY_HUB_PATH="${{ steps.unity-setup.outputs.unity-hub-path }}"
48+
echo "steps.unity-setup.outputs.unity-hub-path: \"${STEPS_UNITY_HUB_PATH}\""
49+
ENV_UNITY_EDITORS='${{ env.UNITY_EDITORS }}' # single quotes to preserve JSON format and quotes from breaking the script
50+
# The json string is raw and not escaped, which breaks echoing it directly. Escape quotes for safe echoing.
51+
ENV_UNITY_EDITORS="${ENV_UNITY_EDITORS//\"/\\\"}"
52+
echo "env.UNITY_EDITORS: \"${ENV_UNITY_EDITORS}\""
53+
STEPS_UNITY_EDITORS='${{ steps.unity-setup.outputs.unity-editors }}' # single quotes to preserve JSON format and quotes from breaking the script
54+
# The json string is raw and not escaped, which breaks echoing it directly. Escape quotes for safe echoing.
55+
STEPS_UNITY_EDITORS="${STEPS_UNITY_EDITORS//\"/\\\"}"
56+
echo "steps.unity-setup.outputs.unity-editors: \"${STEPS_UNITY_EDITORS}\""
57+
ENV_UNITY_EDITOR_PATH="${{ env.UNITY_EDITOR_PATH }}"
58+
echo "env.UNITY_EDITOR_PATH: \"${ENV_UNITY_EDITOR_PATH}\""
59+
STEPS_UNITY_EDITOR_PATH="${{ steps.unity-setup.outputs.unity-editor-path }}"
60+
echo "steps.unity-setup.outputs.unity-editor-path: \"${STEPS_UNITY_EDITOR_PATH}\""
61+
ENV_UNITY_PROJECT_PATH="${{ env.UNITY_PROJECT_PATH }}"
62+
echo "env.UNITY_PROJECT_PATH: \"${ENV_UNITY_PROJECT_PATH}\""
63+
STEPS_UNITY_PROJECT_PATH="${{ steps.unity-setup.outputs.unity-project-path }}"
64+
echo "steps.unity-setup.outputs.unity-project-path: \"${STEPS_UNITY_PROJECT_PATH}\""
65+
66+
# validate both the env and output variables are the same
67+
if [[ "${ENV_UNITY_HUB_PATH}" != "${STEPS_UNITY_HUB_PATH}" ]]; then
68+
echo "Error: UNITY_HUB_PATH env and output do not match!"
69+
exit 1
70+
fi
71+
72+
if [[ "${ENV_UNITY_EDITORS}" != "${STEPS_UNITY_EDITORS}" ]]; then
73+
echo "Error: UNITY_EDITORS env and output do not match!"
74+
exit 1
75+
fi
76+
77+
if [[ "${ENV_UNITY_EDITOR_PATH}" != "${STEPS_UNITY_EDITOR_PATH}" ]]; then
78+
echo "Error: UNITY_EDITOR_PATH env and output do not match!"
79+
exit 1
80+
fi
81+
82+
if [[ "${ENV_UNITY_PROJECT_PATH}" != "${STEPS_UNITY_PROJECT_PATH}" ]]; then
83+
echo "Error: UNITY_PROJECT_PATH env and output do not match!"
84+
exit 1
85+
fi
86+
4887
# If unity-version is None, UNITY_EDITOR_PATH must be empty
4988
if [[ "${{ matrix.unity-version }}" == "None" ]]; then
5089
if [[ -n "${{ env.UNITY_EDITOR_PATH }}" ]]; then

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,21 @@ strategy:
3333
modules: mac-server
3434
steps:
3535
- uses: buildalon/unity-setup@v2
36+
id: unity-setup
3637
with:
3738
version-file: 'path/to/your/unity/project/ProjectSettings/ProjectVersion.txt'
3839
unity-version: ${{ matrix.unity-version }} # overrides version in version-file
3940
build-targets: ${{ matrix.build-targets }}
4041
modules: ${{ matrix.modules }}
4142

4243
- run: |
44+
echo "Step Outputs:"
45+
echo "steps.unity-setup.unity-hub-path: '${{ steps.unity-setup.outputs.unity-hub-path }}'"
46+
echo "steps.unity-setup.unity-editors: '${{ steps.unity-setup.outputs.unity-editors }}'"
47+
echo "steps.unity-setup.unity-editor-path: '${{ steps.unity-setup.outputs.unity-editor-path }}'"
48+
echo "steps.unity-setup.unity-project-path: '${{ steps.unity-setup.outputs.unity-project-path }}'"
49+
50+
echo "Environment Variables:"
4351
echo "UNITY_HUB_PATH: '${{ env.UNITY_HUB_PATH }}'"
4452
echo "UNITY_EDITORS: '${{ env.UNITY_EDITORS }}'"
4553
echo "UNITY_EDITOR_PATH: '${{ env.UNITY_EDITOR_PATH }}'"
@@ -78,7 +86,30 @@ Use any of the following patterns to control how the editor version is resolved:
7886

7987
### outputs
8088

89+
#### step outputs
90+
91+
Steps outputs available for use in subsequent steps:
92+
93+
> [!TIP]
94+
> prefix step outputs with the step id you set in your workflow. In the example above, the step id is `unity-setup`:
95+
>
96+
> `${{ steps.unity-setup.outputs.unity-hub-path }}`
97+
98+
- `unity-hub-path`: The file path to the Unity Hub installation.
99+
- `unity-editors`: A JSON array of all installed Unity Editors on the runner.
100+
- `unity-editor-path`: The path to the latest installed version of Unity.
101+
- `unity-project-path`: The file path to the Unity project.
102+
103+
#### environment variables
104+
105+
Environment variables available for use in subsequent steps:
106+
107+
> [!TIP]
108+
> prefix environment variables with `env.` when using in subsequent steps. For example:
109+
>
110+
> `${{ env.UNITY_HUB_PATH }}`.
111+
81112
- `UNITY_HUB_PATH`: The path to the installed unity hub.
113+
- `UNITY_EDITORS`: A JSON array of all installed Unity Editors on the runner.
114+
- `UNITY_EDITOR_PATH`: The path to the latest installed version of Unity.
82115
- `UNITY_PROJECT_PATH`: The path to the Unity project.
83-
- `UNITY_EDITOR_PATH`: The path to the last installed version of Unity.
84-
- `UNITY_EDITORS`: A json object array of each editor installation `[{"version":"path"},...]`.

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ inputs:
3535
description: 'Specify a specific version of Unity Hub to install. Example: `3.12.0`. When set, auto-update-hub is automatically disabled.'
3636
required: false
3737
default: ''
38+
outputs:
39+
unity-hub-path:
40+
description: 'The file path to the Unity Hub installation.'
41+
unity-editors:
42+
description: 'A JSON array of all installed Unity Editors on the runner.'
43+
unity-editor-path:
44+
description: 'The path to the latest installed version of Unity.'
45+
unity-project-path:
46+
description: 'The file path to the Unity project.'
3847
runs:
3948
using: node20
4049
main: dist/index.js

dist/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42172,7 +42172,7 @@ const entToType = (s) => s.isFile() ? IFREG
4217242172
: s.isFIFO() ? IFIFO
4217342173
: UNKNOWN;
4217442174
// normalize unicode path names
42175-
const normalizeCache = new Map();
42175+
const normalizeCache = new lru_cache_1.LRUCache({ max: 2 ** 12 });
4217642176
const normalize = (s) => {
4217742177
const c = normalizeCache.get(s);
4217842178
if (c)
@@ -42181,7 +42181,7 @@ const normalize = (s) => {
4218142181
normalizeCache.set(s, n);
4218242182
return n;
4218342183
};
42184-
const normalizeNocaseCache = new Map();
42184+
const normalizeNocaseCache = new lru_cache_1.LRUCache({ max: 2 ** 12 });
4218542185
const normalizeNocase = (s) => {
4218642186
const c = normalizeNocaseCache.get(s);
4218742187
if (c)
@@ -42372,6 +42372,7 @@ class PathBase {
4237242372
get parentPath() {
4237342373
return (this.parent || this).fullpath();
4237442374
}
42375+
/* c8 ignore start */
4237542376
/**
4237642377
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
4237742378
* this property refers to the *parent* path, not the path object itself.
@@ -42381,6 +42382,7 @@ class PathBase {
4238142382
get path() {
4238242383
return this.parentPath;
4238342384
}
42385+
/* c8 ignore stop */
4238442386
/**
4238542387
* Do not create new Path objects directly. They should always be accessed
4238642388
* via the PathScurry class or other methods on the Path class.
@@ -59907,7 +59909,7 @@ const entToType = (s) => s.isFile() ? IFREG
5990759909
: s.isFIFO() ? IFIFO
5990859910
: UNKNOWN;
5990959911
// normalize unicode path names
59910-
const normalizeCache = new Map();
59912+
const normalizeCache = new LRUCache({ max: 2 ** 12 });
5991159913
const normalize = (s) => {
5991259914
const c = normalizeCache.get(s);
5991359915
if (c)
@@ -59916,7 +59918,7 @@ const normalize = (s) => {
5991659918
normalizeCache.set(s, n);
5991759919
return n;
5991859920
};
59919-
const normalizeNocaseCache = new Map();
59921+
const normalizeNocaseCache = new LRUCache({ max: 2 ** 12 });
5992059922
const normalizeNocase = (s) => {
5992159923
const c = normalizeNocaseCache.get(s);
5992259924
if (c)
@@ -60105,6 +60107,7 @@ class PathBase {
6010560107
get parentPath() {
6010660108
return (this.parent || this).fullpath();
6010760109
}
60110+
/* c8 ignore start */
6010860111
/**
6010960112
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
6011060113
* this property refers to the *parent* path, not the path object itself.
@@ -60114,6 +60117,7 @@ class PathBase {
6011460117
get path() {
6011560118
return this.parentPath;
6011660119
}
60120+
/* c8 ignore stop */
6011760121
/**
6011860122
* Do not create new Path objects directly. They should always be accessed
6011960123
* via the PathScurry class or other methods on the Path class.
@@ -63593,6 +63597,7 @@ async function main() {
6359363597
if (unityProjectPath) {
6359463598
core.info(`UNITY_PROJECT_PATH:\n > ${unityProjectPath}`);
6359563599
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
63600+
core.setOutput('unity-project-path', unityProjectPath);
6359663601
}
6359763602
let autoUpdate = core.getInput('auto-update-hub');
6359863603
const hubVersion = core.getInput('hub-version');
@@ -63606,6 +63611,7 @@ async function main() {
6360663611
}
6360763612
core.info(`UNITY_HUB_PATH:\n > ${unityHubPath}`);
6360863613
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
63614+
core.setOutput('unity-hub-path', unityHubPath);
6360963615
if (installPath && installPath.length > 0) {
6361063616
await unityHub.SetInstallPath(installPath);
6361163617
}
@@ -63614,6 +63620,7 @@ async function main() {
6361463620
const unityEditor = await unityHub.GetEditor(unityVersion, modules);
6361563621
core.info(`UNITY_EDITOR_PATH:\n > ${unityEditor.editorPath}`);
6361663622
core.exportVariable('UNITY_EDITOR_PATH', unityEditor.editorPath);
63623+
core.setOutput('unity-editor-path', unityEditor.editorPath);
6361763624
if (modules.includes('android') && unityProjectPath !== undefined) {
6361863625
await (0, unity_cli_1.CheckAndroidSdkInstalled)(unityEditor, unityProjectPath);
6361963626
}
@@ -63622,7 +63629,8 @@ async function main() {
6362263629
if (installedEditors.length !== versions.length) {
6362363630
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${installedEditors.length}.`);
6362463631
}
63625-
core.exportVariable('UNITY_EDITORS', Object.fromEntries(installedEditors.map(e => [e.version, e.path])));
63632+
core.exportVariable('UNITY_EDITORS', JSON.stringify(installedEditors));
63633+
core.setOutput('unity-editors', JSON.stringify(installedEditors));
6362663634
core.info('Unity Setup Complete!');
6362763635
process.exit(0);
6362863636
}

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "2.1.2",
3+
"version": "2.2.0",
44
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
55
"author": "Buildalon",
66
"license": "MIT",
@@ -32,7 +32,7 @@
3232
"yaml": "^2.8.1"
3333
},
3434
"devDependencies": {
35-
"@types/node": "^22.18.13",
35+
"@types/node": "^22.19.1",
3636
"@types/semver": "^7.7.1",
3737
"@vercel/ncc": "^0.34.0",
3838
"shx": "^0.4.0",

0 commit comments

Comments
 (0)