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
23 changes: 16 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
schedule:
- cron: '0 0 * * 0' # Run every Sunday at midnight
push:
branches: ['main']
branches: [main]
pull_request:
branches: ['*']
# Allows you to run this workflow manually from the Actions tab
Expand All @@ -25,13 +25,13 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
unity-versions:
- 'in version file'
- '5.6.7f1 (e80cc3114ac1)'
- 2019.4.40f1
unity-version:
- None
- 5.6.7f1 (e80cc3114ac1)
- 2020.3
- 2021.3.x
- 2022.x
- 6000.0.x
- 6000
include:
- os: ubuntu-latest
Expand All @@ -43,17 +43,26 @@ jobs:
- os: macos-latest
build-targets: StandaloneOSX Android iOS VisionOS
modules: mac-server
- os: ubuntu-latest
unity-version: 2019.4.40f1
modules: None
- os: ubuntu-latest
unity-version: 2018.4.36f1 (6cd387d23174)
modules: None
- os: ubuntu-latest
unity-version: 2017.4.40f1 (6e14067f8a9a)
modules: None
exclude:
# Exclude Unity 5.x for linux as it is not supported
- os: ubuntu-latest
unity-versions: '5.6.7f1 (e80cc3114ac1)'
unity-version: '5.6.7f1 (e80cc3114ac1)'
steps:
- uses: actions/checkout@v4

- uses: ./ # RageAgainstThePixel/unity-setup
with:
version-file: 'None'
unity-version: ${{ matrix.unity-versions }}
unity-version: ${{ matrix.unity-version }}
build-targets: ${{ matrix.build-targets }}
modules: ${{ matrix.modules }}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A GitHub Action for setting up the [Unity Game Engine](https://unity.com) on Git
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
unity-versions:
unity-version:
- 'in version file'
- 2019.4.40f1
- 2020.x
Expand All @@ -34,7 +34,7 @@ steps:
- uses: RageAgainstThePixel/unity-setup@v1
with:
version-file: 'path/to/your/ProjectSettings.ProjectVersion.txt'
unity-version: ${{ matrix.unity-versions }} # overrides version in version-file
unity-version: ${{ matrix.unity-version }} # overrides version in version-file
build-targets: ${{ matrix.build-targets }}
modules: ${{ matrix.modules }}

Expand Down
62 changes: 31 additions & 31 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34132,21 +34132,22 @@ async function ValidateInputs() {
core.info(`architecture:\n > ${architecture}`);
}
const buildTargets = getArrayInput('build-targets');
core.info(`modules:`);
const modulesInput = getArrayInput('modules');
if (buildTargets.length == 0) {
if (modulesInput.length > 0) {
modules.push(...modulesInput);
}
else {
modules.push(...getDefaultModules());
if (buildTargets.length == 0 && modulesInput.length === 0) {
modules.push(...getDefaultModules());
for (const module of modules) {
core.info(` > ${module}`);
}
}
else {
modules.push(...modulesInput);
}
core.info(`modules:`);
for (const module of modulesInput) {
core.info(` > ${module}`);
if (module.toLowerCase() == 'none') {
continue;
}
if (!modules.includes(module)) {
modules.push(module);
core.info(` > ${module}`);
}
}
core.info(`buildTargets:`);
const moduleMap = getPlatformTargetModuleMap();
Expand All @@ -34158,11 +34159,8 @@ async function ValidateInputs() {
}
if (!modules.includes(module)) {
modules.push(module);
core.info(` > ${target} -> ${module}`);
}
core.info(` > ${target} -> ${module}`);
}
if (modules.length == 0) {
throw Error('No modules or build-targets provided!');
}
const versions = getUnityVersionsFromInput();
const versionFilePath = await getVersionFilePath();
Expand Down Expand Up @@ -34261,11 +34259,11 @@ function getPlatformTargetModuleMap() {
function getDefaultModules() {
switch (process.platform) {
case 'linux':
return ['linux-il2cpp', 'android', 'ios'];
return ['linux-il2cpp'];
case 'darwin':
return ['mac-il2cpp', 'android', 'ios'];
return ['mac-il2cpp'];
case 'win32':
return ['windows-il2cpp', 'android', 'universal-windows-platform'];
return ['windows-il2cpp'];
default:
throw Error(`${process.platform} not supported`);
}
Expand Down Expand Up @@ -34477,7 +34475,7 @@ async function execSdkManager(sdkManagerPath, javaSdk, args) {

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Get = Get;
exports.setInstallPath = setInstallPath;
exports.SetInstallPath = SetInstallPath;
exports.Unity = Unity;
exports.ListInstalledEditors = ListInstalledEditors;
const utility_1 = __nccwpck_require__(5418);
Expand Down Expand Up @@ -34557,6 +34555,10 @@ async function Get() {
}
return hubPath;
}
async function SetInstallPath(installPath) {
await fs.promises.mkdir(installPath, { recursive: true });
await execUnityHub(["install-path", "--set", installPath]);
}
async function installUnityHub() {
let exitCode = undefined;
switch (process.platform) {
Expand Down Expand Up @@ -34722,10 +34724,6 @@ const retryErrorMessages = [
'Editor already installed in this location',
'failed to download. Error given: Request timeout'
];
async function setInstallPath(installPath) {
await fs.promises.mkdir(installPath, { recursive: true });
await execUnityHub(["install-path", "--set", installPath]);
}
async function Unity(version, changeset, architecture, modules) {
if (os.arch() == 'arm64' && !isArmCompatible(version)) {
core.warning(`Unity ${version} does not support arm64 architecture, falling back to x86_64`);
Expand Down Expand Up @@ -34974,12 +34972,14 @@ async function getChangeset(version) {
return null;
}
async function removePath(targetPath) {
core.startGroup(`deleting ${targetPath}...`);
try {
await fs.promises.rm(targetPath, { recursive: true, force: true });
}
finally {
core.endGroup();
if (targetPath && targetPath.length > 0) {
core.startGroup(`deleting ${targetPath}...`);
try {
await fs.promises.rm(targetPath, { recursive: true, force: true });
}
finally {
core.endGroup();
}
}
}

Expand Down Expand Up @@ -45597,8 +45597,8 @@ const main = async () => {
}
const unityHubPath = await unityHub.Get();
core.exportVariable('UNITY_HUB_PATH', unityHubPath);
if (installPath.length > 0) {
await unityHub.setInstallPath(installPath);
if (installPath && installPath.length > 0) {
await unityHub.SetInstallPath(installPath);
}
const editors = [];
for (const [version, changeset] of versions) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

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.1.0",
"version": "1.1.1",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ const main = async () => {
}
const unityHubPath = await unityHub.Get();
core.exportVariable('UNITY_HUB_PATH', unityHubPath);

if (installPath.length > 0) {
await unityHub.setInstallPath(installPath);
if (installPath && installPath.length > 0) {
await unityHub.SetInstallPath(installPath);
}

const editors = [];
for (const [version, changeset] of versions) {
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);
Expand Down
34 changes: 17 additions & 17 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@ import os = require('os');
import fs = require('fs');

export async function ValidateInputs(): Promise<[string[][], string | undefined, string[], string | undefined, string]> {
const modules = [];
const modules: string[] = [];
const architecture = core.getInput('architecture') || getInstallationArch();
if (architecture) {
core.info(`architecture:\n > ${architecture}`);
}
const buildTargets = getArrayInput('build-targets');
core.info(`modules:`);
const modulesInput = getArrayInput('modules');
if (buildTargets.length == 0) {
if (modulesInput.length > 0) {
modules.push(...modulesInput);
} else {
modules.push(...getDefaultModules());
if (buildTargets.length == 0 && modulesInput.length === 0) {
modules.push(...getDefaultModules());
for (const module of modules) {
core.info(` > ${module}`);
}
} else {
modules.push(...modulesInput);
}
core.info(`modules:`);
for (const module of modulesInput) {
core.info(` > ${module}`);
if (module.toLowerCase() == 'none') {
continue;
}
if (!modules.includes(module)) {
modules.push(module);
core.info(` > ${module}`);
}
}
core.info(`buildTargets:`);
const moduleMap = getPlatformTargetModuleMap();
Expand All @@ -36,11 +39,8 @@ export async function ValidateInputs(): Promise<[string[][], string | undefined,
}
if (!modules.includes(module)) {
modules.push(module);
core.info(` > ${target} -> ${module}`);
}
core.info(` > ${target} -> ${module}`);
}
if (modules.length == 0) {
throw Error('No modules or build-targets provided!');
}
const versions = getUnityVersionsFromInput();
const versionFilePath = await getVersionFilePath();
Expand Down Expand Up @@ -137,11 +137,11 @@ function getPlatformTargetModuleMap(): { [key: string]: string } {
function getDefaultModules(): string[] {
switch (process.platform) {
case 'linux':
return ['linux-il2cpp', 'android', 'ios'];
return ['linux-il2cpp'];
case 'darwin':
return ['mac-il2cpp', 'android', 'ios'];
return ['mac-il2cpp'];
case 'win32':
return ['windows-il2cpp', 'android', 'universal-windows-platform'];
return ['windows-il2cpp'];
default:
throw Error(`${process.platform} not supported`);
}
Expand Down
26 changes: 14 additions & 12 deletions src/unity-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export async function Get(): Promise<string> {
return hubPath;
}

export async function SetInstallPath(installPath: string): Promise<void> {
await fs.promises.mkdir(installPath, { recursive: true });
await execUnityHub(["install-path", "--set", installPath]);
}

async function installUnityHub(): Promise<string> {
let exitCode = undefined;
switch (process.platform) {
Expand Down Expand Up @@ -245,11 +250,6 @@ const retryErrorMessages = [
'failed to download. Error given: Request timeout'
];

export async function setInstallPath(installPath: string): Promise<void> {
await fs.promises.mkdir(installPath, { recursive: true });
await execUnityHub(["install-path", "--set", installPath]);
}

export async function Unity(version: string, changeset: string, architecture: string, modules: string[]): Promise<string> {
if (os.arch() == 'arm64' && !isArmCompatible(version)) {
core.warning(`Unity ${version} does not support arm64 architecture, falling back to x86_64`);
Expand Down Expand Up @@ -500,11 +500,13 @@ async function getChangeset(version: string): Promise<string | null> {
return null;
}

async function removePath(targetPath: string): Promise<void> {
core.startGroup(`deleting ${targetPath}...`);
try {
await fs.promises.rm(targetPath, { recursive: true, force: true });
} finally {
core.endGroup();
async function removePath(targetPath: string | undefined): Promise<void> {
if (targetPath && targetPath.length > 0) {
core.startGroup(`deleting ${targetPath}...`);
try {
await fs.promises.rm(targetPath, { recursive: true, force: true });
} finally {
core.endGroup();
}
}
}
}
Loading