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
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
branches: [main]
pull_request:
branches: ['*']
types: [opened, synchronize, reopened, ready_for_review]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
31 changes: 18 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35984,7 +35984,7 @@ async function installUnityHub() {
case 'darwin':
{
const scriptPath = __nccwpck_require__.ab + "install-unityhub-macos.sh";
exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "install-unityhub-macos.sh"]);
exitCode = await exec.exec('bash', [__nccwpck_require__.ab + "install-unityhub-macos.sh"]);
if (exitCode !== 0) {
throw new Error(`Failed to install Unity Hub: ${exitCode}`);
}
Expand All @@ -35995,7 +35995,7 @@ async function installUnityHub() {
{
const scriptPath = __nccwpck_require__.ab + "install-unityhub-linux.sh";
let output = '';
exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "install-unityhub-linux.sh"], {
exitCode = await exec.exec('bash', [__nccwpck_require__.ab + "install-unityhub-linux.sh"], {
listeners: {
stdout: (data) => {
output += data.toString();
Expand Down Expand Up @@ -36133,7 +36133,7 @@ const retryErrorMessages = [
async function UnityEditor(unityVersion, modules) {
core.info(`Getting release info for Unity ${unityVersion.toString()}...`);
let editorPath = await checkInstalledEditors(unityVersion, false);
if (!unityVersion.isLegacy() && !editorPath) {
if (!unityVersion.isLegacy() && !editorPath && !unityVersion.changeset) {
try {
const releases = await getLatestHubReleases();
unityVersion = unityVersion.findMatch(releases);
Expand All @@ -36142,7 +36142,12 @@ async function UnityEditor(unityVersion, modules) {
}
catch (error) {
core.warning(`Failed to get Unity release info for ${unityVersion.toString()}! falling back to legacy search...\n${error}`);
unityVersion = await fallbackVersionLookup(unityVersion);
try {
unityVersion = await fallbackVersionLookup(unityVersion);
}
catch (fallbackError) {
core.warning(`Failed to lookup changeset for Unity ${unityVersion.toString()}!\n${fallbackError}`);
}
}
}
let installPath = null;
Expand Down Expand Up @@ -36232,7 +36237,7 @@ async function installUnity(unityVersion, modules) {
core.startGroup(`Installing Unity ${unityVersion.toString()}...`);
if (process.platform === 'linux') {
const installLinuxDepsScript = __nccwpck_require__.ab + "install-linux-dependencies.sh";
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "install-linux-dependencies.sh", unityVersion.version], {
const exitCode = await exec.exec('bash', [__nccwpck_require__.ab + "install-linux-dependencies.sh", unityVersion.version], {
ignoreReturnCode: true
});
if (exitCode !== 0) {
Expand Down Expand Up @@ -36288,7 +36293,7 @@ async function installUnity4x(unityVersion) {
const installPath = path.join(installDir, `Unity ${unityVersion.version}`, 'Unity.app');
if (!fs.existsSync(installPath)) {
const scriptPath = __nccwpck_require__.ab + "unity-editor-installer.sh";
const exitCode = await exec.exec('sh', [__nccwpck_require__.ab + "unity-editor-installer.sh", unityVersion.version, installDir], {
const exitCode = await exec.exec('bash', [__nccwpck_require__.ab + "unity-editor-installer.sh", unityVersion.version, installDir], {
ignoreReturnCode: true
});
if (exitCode !== 0) {
Expand Down Expand Up @@ -36437,7 +36442,7 @@ async function getEditorReleaseInfo(unityVersion) {
core.debug(`Get Unity Release: ${JSON.stringify(request, null, 2)}`);
const { data, error } = await releasesClient.api.ReleaseService.getUnityReleases(request);
if (error) {
throw new Error(`Failed to get Unity releases: ${error}`);
throw new Error(`Failed to get Unity releases: ${JSON.stringify(error, null, 2)}`);
}
if (!data || !data.results || data.results.length === 0) {
throw new Error(`No Unity releases found for version: ${version}`);
Expand Down Expand Up @@ -36480,7 +36485,7 @@ async function fallbackVersionLookup(unityVersion) {
return unityVersion;
}
const responseText = await response.text();
if (core.isDebug()) {
if (core.isDebug() || !response.ok) {
core.info(responseText);
}
if (!response.ok) {
Expand Down Expand Up @@ -47277,20 +47282,20 @@ const main = async () => {
if (installPath && installPath.length > 0) {
await unityHub.SetInstallPath(installPath);
}
const editors = [];
const installedEditors = [];
for (const unityVersion of versions) {
const unityEditorPath = await unityHub.UnityEditor(unityVersion, modules);
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath);
if (modules.includes('android') && unityProjectPath !== undefined) {
await (0, install_android_sdk_1.CheckAndroidSdkInstalled)(unityEditorPath, unityProjectPath);
}
core.info(`Installed Unity Editor: ${unityVersion.toString()} at ${unityEditorPath}`);
editors.push([unityVersion.version, unityEditorPath]);
installedEditors.push({ version: unityVersion.version, path: unityEditorPath });
}
if (editors.length !== versions.length) {
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${editors.length}.`);
if (installedEditors.length !== versions.length) {
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${installedEditors.length}.`);
}
core.exportVariable('UNITY_EDITORS', JSON.stringify(Object.fromEntries(editors)));
core.exportVariable('UNITY_EDITORS', JSON.stringify(Object.fromEntries(installedEditors.map(e => [e.version, e.path]))));
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.

12 changes: 8 additions & 4 deletions dist/install-linux-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ fi
echo "::group::Installing additional dependencies for Unity $unityVersion..."

# Unity 2019.{1,2}
if [[ "$unityVersion" =~ ^2019\.[12]\. ]]; then
case "$unityVersion" in
2019.1.*|2019.2.*)
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
rm libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
fi
;;
esac

# Unity 2019.{3,4}/2020.*
if [[ "$unityVersion" =~ ^2019\.[34]\. ]] || [[ "$unityVersion" =~ ^2020\. ]]; then
case "$unityVersion" in
2019.3.*|2019.4.*|2020.*)
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
rm libssl1.1_1.1.0g-2ubuntu4_amd64.deb
fi
;;
esac

echo "::endgroup::"
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.2.6",
"version": "1.3.0",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down
23 changes: 16 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,42 @@ import core = require('@actions/core');
const main = async () => {
try {
const [versions, modules, unityProjectPath, installPath] = await ValidateInputs();

if (unityProjectPath) {
core.exportVariable('UNITY_PROJECT_PATH', unityProjectPath);
}

const unityHubPath = await unityHub.Get();
core.exportVariable('UNITY_HUB_PATH', unityHubPath);

if (installPath && installPath.length > 0) {
await unityHub.SetInstallPath(installPath);
}
const editors = [];

const installedEditors: { version: string; path: string }[] = [];

for (const unityVersion of versions) {
const unityEditorPath = await unityHub.UnityEditor(unityVersion, modules);
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath); // always sets the last installed editor path
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath); // always sets to the latest installed editor path

if (modules.includes('android') && unityProjectPath !== undefined) {
await CheckAndroidSdkInstalled(unityEditorPath, unityProjectPath);
}

core.info(`Installed Unity Editor: ${unityVersion.toString()} at ${unityEditorPath}`);
editors.push([unityVersion.version, unityEditorPath]);
installedEditors.push({ version: unityVersion.version, path: unityEditorPath });
}
if (editors.length !== versions.length) {
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${editors.length}.`);

if (installedEditors.length !== versions.length) {
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${installedEditors.length}.`);
}
core.exportVariable('UNITY_EDITORS', JSON.stringify(Object.fromEntries(editors)));

core.exportVariable('UNITY_EDITORS', JSON.stringify(Object.fromEntries(installedEditors.map(e => [e.version, e.path]))));
core.info('Unity Setup Complete!');
process.exit(0);
} catch (error) {
core.setFailed(error.stack);
}
}
};

main();
12 changes: 8 additions & 4 deletions src/install-linux-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ fi
echo "::group::Installing additional dependencies for Unity $unityVersion..."

# Unity 2019.{1,2}
if [[ "$unityVersion" =~ ^2019\.[12]\. ]]; then
case "$unityVersion" in
2019.1.*|2019.2.*)
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
rm libssl1.0.0_1.0.2g-1ubuntu4.20_amd64.deb
fi
;;
esac

# Unity 2019.{3,4}/2020.*
if [[ "$unityVersion" =~ ^2019\.[34]\. ]] || [[ "$unityVersion" =~ ^2020\. ]]; then
case "$unityVersion" in
2019.3.*|2019.4.*|2020.*)
curl -LO https://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
rm libssl1.1_1.1.0g-2ubuntu4_amd64.deb
fi
;;
esac

echo "::endgroup::"
36 changes: 28 additions & 8 deletions src/unity-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ async function installUnityHub(): Promise<string> {
case 'darwin':
{
const scriptPath = path.join(__dirname, 'install-unityhub-macos.sh');
exitCode = await exec.exec('sh', [scriptPath]);
// Use bash to respect script shebang and any bash-specific features
exitCode = await exec.exec('bash', [scriptPath]);
if (exitCode !== 0) {
throw new Error(`Failed to install Unity Hub: ${exitCode}`);
}
Expand All @@ -148,7 +149,8 @@ async function installUnityHub(): Promise<string> {
{
const scriptPath = path.join(__dirname, 'install-unityhub-linux.sh');
let output = '';
exitCode = await exec.exec('sh', [scriptPath], {
// Use bash to respect script shebang and any bash-specific features
exitCode = await exec.exec('bash', [scriptPath], {
listeners: {
stdout: (data) => {
output += data.toString();
Expand Down Expand Up @@ -290,18 +292,26 @@ const retryErrorMessages = [
export async function UnityEditor(unityVersion: UnityVersion, modules: string[]): Promise<string> {
core.info(`Getting release info for Unity ${unityVersion.toString()}...`);
let editorPath = await checkInstalledEditors(unityVersion, false);
if (!unityVersion.isLegacy() && !editorPath) {

// attempt to resolve the full version with the changeset if we don't have one already
if (!unityVersion.isLegacy() && !editorPath && !unityVersion.changeset) {
try {
const releases = await getLatestHubReleases();
unityVersion = unityVersion.findMatch(releases);
const unityReleaseInfo: UnityRelease = await getEditorReleaseInfo(unityVersion);
unityVersion = new UnityVersion(unityReleaseInfo.version, unityReleaseInfo.shortRevision, unityVersion.architecture);
} catch (error) {
core.warning(`Failed to get Unity release info for ${unityVersion.toString()}! falling back to legacy search...\n${error}`);
unityVersion = await fallbackVersionLookup(unityVersion);
try {
unityVersion = await fallbackVersionLookup(unityVersion);
} catch (fallbackError) {
core.warning(`Failed to lookup changeset for Unity ${unityVersion.toString()}!\n${fallbackError}`);
}
}
}

let installPath: string | null = null;

if (!editorPath) {
try {
installPath = await installUnity(unityVersion, modules);
Expand All @@ -310,6 +320,7 @@ export async function UnityEditor(unityVersion: UnityVersion, modules: string[])
if (editorPath) {
await RemovePath(editorPath);
}

if (installPath) {
await RemovePath(installPath);
}
Expand All @@ -318,25 +329,32 @@ export async function UnityEditor(unityVersion: UnityVersion, modules: string[])
throw error;
}
}

editorPath = await checkInstalledEditors(unityVersion, true, installPath);
}

await fs.promises.access(editorPath, fs.constants.X_OK);
core.info(`Unity Editor Path:\n > "${editorPath}"`);
await patchBeeBackend(editorPath);

if (unityVersion.isLegacy() || modules.length === 0) {
return editorPath;
}

try {
core.startGroup(`Checking installed modules for Unity ${unityVersion.toString()}...`);
const [installedModules, additionalModules] = await checkEditorModules(editorPath, unityVersion, modules);

if (installedModules && installedModules.length > 0) {
core.info(`Installed Modules:`);

for (const module of installedModules) {
core.info(` > ${module}`);
}
}
if (additionalModules && additionalModules.length > 0) {
core.info(`Additional Modules:`);

for (const module of additionalModules) {
core.info(` > ${module}`);
}
Expand All @@ -349,6 +367,7 @@ export async function UnityEditor(unityVersion: UnityVersion, modules: string[])
} finally {
core.endGroup();
}

return editorPath;
}

Expand Down Expand Up @@ -400,7 +419,7 @@ async function installUnity(unityVersion: UnityVersion, modules: string[]): Prom

if (process.platform === 'linux') {
const installLinuxDepsScript = path.join(__dirname, 'install-linux-dependencies.sh');
const exitCode = await exec.exec('sh', [installLinuxDepsScript, unityVersion.version], {
const exitCode = await exec.exec('bash', [installLinuxDepsScript, unityVersion.version], {
ignoreReturnCode: true
});

Expand Down Expand Up @@ -467,7 +486,8 @@ async function installUnity4x(unityVersion: UnityVersion): Promise<string> {

if (!fs.existsSync(installPath)) {
const scriptPath = path.join(__dirname, 'unity-editor-installer.sh');
const exitCode = await exec.exec('sh', [scriptPath, unityVersion.version, installDir], {
// Use bash to respect script shebang and any bash-specific features
const exitCode = await exec.exec('bash', [scriptPath, unityVersion.version, installDir], {
ignoreReturnCode: true
});

Expand Down Expand Up @@ -630,7 +650,7 @@ export async function getEditorReleaseInfo(unityVersion: UnityVersion): Promise<
const { data, error } = await releasesClient.api.ReleaseService.getUnityReleases(request);

if (error) {
throw new Error(`Failed to get Unity releases: ${error}`);
throw new Error(`Failed to get Unity releases: ${JSON.stringify(error, null, 2)}`);
}

if (!data || !data.results || data.results.length === 0) {
Expand Down Expand Up @@ -681,7 +701,7 @@ async function fallbackVersionLookup(unityVersion: UnityVersion): Promise<UnityV

const responseText = await response.text();

if (core.isDebug()) {
if (core.isDebug() || !response.ok) {
core.info(responseText);
}

Expand Down
Loading