Skip to content

Commit bc63961

Browse files
- add support for `modules: None` input - reduced default installed modules to only il2cpp per platform
1 parent 03035e7 commit bc63961

File tree

9 files changed

+86
-77
lines changed

9 files changed

+86
-77
lines changed

.github/workflows/validate.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
schedule:
44
- cron: '0 0 * * 0' # Run every Sunday at midnight
55
push:
6-
branches: ['main']
6+
branches: [main]
77
pull_request:
88
branches: ['*']
99
# Allows you to run this workflow manually from the Actions tab
@@ -25,13 +25,13 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
os: [ubuntu-latest, windows-latest, macos-latest]
28-
unity-versions:
29-
- 'in version file'
30-
- '5.6.7f1 (e80cc3114ac1)'
31-
- 2019.4.40f1
28+
unity-version:
29+
- None
30+
- 5.6.7f1 (e80cc3114ac1)
3231
- 2020.3
3332
- 2021.3.x
3433
- 2022.x
34+
- 6000.0.x
3535
- 6000
3636
include:
3737
- os: ubuntu-latest
@@ -43,17 +43,26 @@ jobs:
4343
- os: macos-latest
4444
build-targets: StandaloneOSX Android iOS VisionOS
4545
modules: mac-server
46+
- os: ubuntu-latest
47+
unity-version: 2019.4.40f1
48+
modules: None
49+
- os: ubuntu-latest
50+
unity-version: 2018.4.36f1 (6cd387d23174)
51+
modules: None
52+
- os: ubuntu-latest
53+
unity-version: 2017.4.40f1 (6e14067f8a9a)
54+
modules: None
4655
exclude:
4756
# Exclude Unity 5.x for linux as it is not supported
4857
- os: ubuntu-latest
49-
unity-versions: '5.6.7f1 (e80cc3114ac1)'
58+
unity-version: '5.6.7f1 (e80cc3114ac1)'
5059
steps:
5160
- uses: actions/checkout@v4
5261

5362
- uses: ./ # RageAgainstThePixel/unity-setup
5463
with:
5564
version-file: 'None'
56-
unity-version: ${{ matrix.unity-versions }}
65+
unity-version: ${{ matrix.unity-version }}
5766
build-targets: ${{ matrix.build-targets }}
5867
modules: ${{ matrix.modules }}
5968

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A GitHub Action for setting up the [Unity Game Engine](https://unity.com) on Git
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest, windows-latest, macos-latest]
13-
unity-versions:
13+
unity-version:
1414
- 'in version file'
1515
- 2019.4.40f1
1616
- 2020.x
@@ -34,7 +34,7 @@ steps:
3434
- uses: RageAgainstThePixel/unity-setup@v1
3535
with:
3636
version-file: 'path/to/your/ProjectSettings.ProjectVersion.txt'
37-
unity-version: ${{ matrix.unity-versions }} # overrides version in version-file
37+
unity-version: ${{ matrix.unity-version }} # overrides version in version-file
3838
build-targets: ${{ matrix.build-targets }}
3939
modules: ${{ matrix.modules }}
4040

dist/index.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34132,21 +34132,22 @@ async function ValidateInputs() {
3413234132
core.info(`architecture:\n > ${architecture}`);
3413334133
}
3413434134
const buildTargets = getArrayInput('build-targets');
34135+
core.info(`modules:`);
3413534136
const modulesInput = getArrayInput('modules');
34136-
if (buildTargets.length == 0) {
34137-
if (modulesInput.length > 0) {
34138-
modules.push(...modulesInput);
34139-
}
34140-
else {
34141-
modules.push(...getDefaultModules());
34137+
if (buildTargets.length == 0 && modulesInput.length === 0) {
34138+
modules.push(...getDefaultModules());
34139+
for (const module of modules) {
34140+
core.info(` > ${module}`);
3414234141
}
3414334142
}
34144-
else {
34145-
modules.push(...modulesInput);
34146-
}
34147-
core.info(`modules:`);
3414834143
for (const module of modulesInput) {
34149-
core.info(` > ${module}`);
34144+
if (module.toLowerCase() == 'none') {
34145+
continue;
34146+
}
34147+
if (!modules.includes(module)) {
34148+
modules.push(module);
34149+
core.info(` > ${module}`);
34150+
}
3415034151
}
3415134152
core.info(`buildTargets:`);
3415234153
const moduleMap = getPlatformTargetModuleMap();
@@ -34158,11 +34159,8 @@ async function ValidateInputs() {
3415834159
}
3415934160
if (!modules.includes(module)) {
3416034161
modules.push(module);
34162+
core.info(` > ${target} -> ${module}`);
3416134163
}
34162-
core.info(` > ${target} -> ${module}`);
34163-
}
34164-
if (modules.length == 0) {
34165-
throw Error('No modules or build-targets provided!');
3416634164
}
3416734165
const versions = getUnityVersionsFromInput();
3416834166
const versionFilePath = await getVersionFilePath();
@@ -34261,11 +34259,11 @@ function getPlatformTargetModuleMap() {
3426134259
function getDefaultModules() {
3426234260
switch (process.platform) {
3426334261
case 'linux':
34264-
return ['linux-il2cpp', 'android', 'ios'];
34262+
return ['linux-il2cpp'];
3426534263
case 'darwin':
34266-
return ['mac-il2cpp', 'android', 'ios'];
34264+
return ['mac-il2cpp'];
3426734265
case 'win32':
34268-
return ['windows-il2cpp', 'android', 'universal-windows-platform'];
34266+
return ['windows-il2cpp'];
3426934267
default:
3427034268
throw Error(`${process.platform} not supported`);
3427134269
}
@@ -34477,7 +34475,7 @@ async function execSdkManager(sdkManagerPath, javaSdk, args) {
3447734475

3447834476
Object.defineProperty(exports, "__esModule", ({ value: true }));
3447934477
exports.Get = Get;
34480-
exports.setInstallPath = setInstallPath;
34478+
exports.SetInstallPath = SetInstallPath;
3448134479
exports.Unity = Unity;
3448234480
exports.ListInstalledEditors = ListInstalledEditors;
3448334481
const utility_1 = __nccwpck_require__(5418);
@@ -34557,6 +34555,10 @@ async function Get() {
3455734555
}
3455834556
return hubPath;
3455934557
}
34558+
async function SetInstallPath(installPath) {
34559+
await fs.promises.mkdir(installPath, { recursive: true });
34560+
await execUnityHub(["install-path", "--set", installPath]);
34561+
}
3456034562
async function installUnityHub() {
3456134563
let exitCode = undefined;
3456234564
switch (process.platform) {
@@ -34722,10 +34724,6 @@ const retryErrorMessages = [
3472234724
'Editor already installed in this location',
3472334725
'failed to download. Error given: Request timeout'
3472434726
];
34725-
async function setInstallPath(installPath) {
34726-
await fs.promises.mkdir(installPath, { recursive: true });
34727-
await execUnityHub(["install-path", "--set", installPath]);
34728-
}
3472934727
async function Unity(version, changeset, architecture, modules) {
3473034728
if (os.arch() == 'arm64' && !isArmCompatible(version)) {
3473134729
core.warning(`Unity ${version} does not support arm64 architecture, falling back to x86_64`);
@@ -34974,12 +34972,14 @@ async function getChangeset(version) {
3497434972
return null;
3497534973
}
3497634974
async function removePath(targetPath) {
34977-
core.startGroup(`deleting ${targetPath}...`);
34978-
try {
34979-
await fs.promises.rm(targetPath, { recursive: true, force: true });
34980-
}
34981-
finally {
34982-
core.endGroup();
34975+
if (targetPath && targetPath.length > 0) {
34976+
core.startGroup(`deleting ${targetPath}...`);
34977+
try {
34978+
await fs.promises.rm(targetPath, { recursive: true, force: true });
34979+
}
34980+
finally {
34981+
core.endGroup();
34982+
}
3498334983
}
3498434984
}
3498534985

@@ -45597,8 +45597,8 @@ const main = async () => {
4559745597
}
4559845598
const unityHubPath = await unityHub.Get();
4559945599
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
45600-
if (installPath.length > 0) {
45601-
await unityHub.setInstallPath(installPath);
45600+
if (installPath && installPath.length > 0) {
45601+
await unityHub.SetInstallPath(installPath);
4560245602
}
4560345603
const editors = [];
4560445604
for (const [version, changeset] of versions) {

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: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unity-setup",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ const main = async () => {
1111
}
1212
const unityHubPath = await unityHub.Get();
1313
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
14-
15-
if (installPath.length > 0) {
16-
await unityHub.setInstallPath(installPath);
14+
if (installPath && installPath.length > 0) {
15+
await unityHub.SetInstallPath(installPath);
1716
}
18-
1917
const editors = [];
2018
for (const [version, changeset] of versions) {
2119
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);

src/inputs.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,28 @@ import os = require('os');
66
import fs = require('fs');
77

88
export async function ValidateInputs(): Promise<[string[][], string | undefined, string[], string | undefined, string]> {
9-
const modules = [];
9+
const modules: string[] = [];
1010
const architecture = core.getInput('architecture') || getInstallationArch();
1111
if (architecture) {
1212
core.info(`architecture:\n > ${architecture}`);
1313
}
1414
const buildTargets = getArrayInput('build-targets');
15+
core.info(`modules:`);
1516
const modulesInput = getArrayInput('modules');
16-
if (buildTargets.length == 0) {
17-
if (modulesInput.length > 0) {
18-
modules.push(...modulesInput);
19-
} else {
20-
modules.push(...getDefaultModules());
17+
if (buildTargets.length == 0 && modulesInput.length === 0) {
18+
modules.push(...getDefaultModules());
19+
for (const module of modules) {
20+
core.info(` > ${module}`);
2121
}
22-
} else {
23-
modules.push(...modulesInput);
2422
}
25-
core.info(`modules:`);
2623
for (const module of modulesInput) {
27-
core.info(` > ${module}`);
24+
if (module.toLowerCase() == 'none') {
25+
continue;
26+
}
27+
if (!modules.includes(module)) {
28+
modules.push(module);
29+
core.info(` > ${module}`);
30+
}
2831
}
2932
core.info(`buildTargets:`);
3033
const moduleMap = getPlatformTargetModuleMap();
@@ -36,11 +39,8 @@ export async function ValidateInputs(): Promise<[string[][], string | undefined,
3639
}
3740
if (!modules.includes(module)) {
3841
modules.push(module);
42+
core.info(` > ${target} -> ${module}`);
3943
}
40-
core.info(` > ${target} -> ${module}`);
41-
}
42-
if (modules.length == 0) {
43-
throw Error('No modules or build-targets provided!');
4444
}
4545
const versions = getUnityVersionsFromInput();
4646
const versionFilePath = await getVersionFilePath();
@@ -137,11 +137,11 @@ function getPlatformTargetModuleMap(): { [key: string]: string } {
137137
function getDefaultModules(): string[] {
138138
switch (process.platform) {
139139
case 'linux':
140-
return ['linux-il2cpp', 'android', 'ios'];
140+
return ['linux-il2cpp'];
141141
case 'darwin':
142-
return ['mac-il2cpp', 'android', 'ios'];
142+
return ['mac-il2cpp'];
143143
case 'win32':
144-
return ['windows-il2cpp', 'android', 'universal-windows-platform'];
144+
return ['windows-il2cpp'];
145145
default:
146146
throw Error(`${process.platform} not supported`);
147147
}

src/unity-hub.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ export async function Get(): Promise<string> {
7676
return hubPath;
7777
}
7878

79+
export async function SetInstallPath(installPath: string): Promise<void> {
80+
await fs.promises.mkdir(installPath, { recursive: true });
81+
await execUnityHub(["install-path", "--set", installPath]);
82+
}
83+
7984
async function installUnityHub(): Promise<string> {
8085
let exitCode = undefined;
8186
switch (process.platform) {
@@ -245,11 +250,6 @@ const retryErrorMessages = [
245250
'failed to download. Error given: Request timeout'
246251
];
247252

248-
export async function setInstallPath(installPath: string): Promise<void> {
249-
await fs.promises.mkdir(installPath, { recursive: true });
250-
await execUnityHub(["install-path", "--set", installPath]);
251-
}
252-
253253
export async function Unity(version: string, changeset: string, architecture: string, modules: string[]): Promise<string> {
254254
if (os.arch() == 'arm64' && !isArmCompatible(version)) {
255255
core.warning(`Unity ${version} does not support arm64 architecture, falling back to x86_64`);
@@ -500,11 +500,13 @@ async function getChangeset(version: string): Promise<string | null> {
500500
return null;
501501
}
502502

503-
async function removePath(targetPath: string): Promise<void> {
504-
core.startGroup(`deleting ${targetPath}...`);
505-
try {
506-
await fs.promises.rm(targetPath, { recursive: true, force: true });
507-
} finally {
508-
core.endGroup();
503+
async function removePath(targetPath: string | undefined): Promise<void> {
504+
if (targetPath && targetPath.length > 0) {
505+
core.startGroup(`deleting ${targetPath}...`);
506+
try {
507+
await fs.promises.rm(targetPath, { recursive: true, force: true });
508+
} finally {
509+
core.endGroup();
510+
}
509511
}
510-
}
512+
}

0 commit comments

Comments
 (0)