Skip to content
Open
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
12 changes: 12 additions & 0 deletions .github/workflows/build-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"6000.2"
],
"include": [
{
"os": "ubuntu-latest",
"unity-version": "none"
},
{
"os": "ubuntu-latest",
"build-target": "StandaloneLinux64"
Expand All @@ -31,10 +35,18 @@
"os": "ubuntu-latest",
"build-target": "Android"
},
{
"os": "windows-latest",
"unity-version": "none"
},
{
"os": "windows-latest",
"build-target": "StandaloneWindows64"
},
{
"os": "macos-latest",
"unity-version": "none"
},
{
"os": "windows-latest",
"build-target": "Android"
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/unity-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ jobs:
timeout-minutes: 30
run: |
unity-cli hub-install --auto-update
unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-target }}" --json
if [ "${{ matrix.unity-version }}" != "none" ]; then
unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-target }}" --json
fi
- name: Verify UNITY_HUB_PATH and UNITY_EDITOR_PATH variables
shell: bash
run: |
Expand All @@ -61,20 +63,23 @@ jobs:
exit 1
fi

if [ -z "${UNITY_EDITOR_PATH}" ]; then
if [ "${{ matrix.unity-version }}" != "none" ] && [ -z "${UNITY_EDITOR_PATH}" ]; then
echo "Error: UNITY_EDITOR_PATH is not set"
exit 1
fi
- name: Activate License
if : ${{ matrix.unity-version != 'none' }}
shell: bash
run: |
unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
- name: Create Unity Project
if : ${{ matrix.unity-version != 'none' }}
shell: bash
run: |
unity-cli list-project-templates --unity-editor "${UNITY_EDITOR_PATH}" --json
unity-cli create-project --name "Unity Project" --unity-editor "${UNITY_EDITOR_PATH}" --json
- name: Verify UNITY_PROJECT_PATH variable
if : ${{ matrix.unity-version != 'none' }}
shell: bash
run: |
if [ -z "${UNITY_PROJECT_PATH}" ]; then
Expand Down Expand Up @@ -119,6 +124,7 @@ jobs:
unity-cli run --log-name Validate -quit -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset
unity-cli run --log-name Build -buildTarget ${{ matrix.build-target }} -quit -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity ${{ matrix.build-args }}
- name: Uninstall Editor
if: ${{ matrix.unity-version != 'none' }}
shell: bash
run: |
if [ -z "${UNITY_EDITOR_PATH}" ]; then
Expand Down
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": "@rage-against-the-pixel/unity-cli",
"version": "1.5.0",
"version": "1.5.1",
"description": "A command line utility for the Unity Game Engine.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/license-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class LicensingClient {
await fs.promises.access(this.unityHub.executable, fs.constants.R_OK);
await fs.promises.access(this.unityHub.rootDirectory, fs.constants.R_OK);
} catch (error) {
await this.unityHub.Install();
throw new Error('Unity Hub is not installed or not accessible. Please install Unity Hub before using the Licensing Client.');
}

const licensingClientExecutable = process.platform === 'win32' ? 'Unity.Licensing.Client.exe' : 'Unity.Licensing.Client';
Expand Down
8 changes: 8 additions & 0 deletions src/unity-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export class UnityEditor {

this.autoAddNoGraphics = this.version.isGreaterThan('2018.0.0');

// check if we have permissions to write to this file
try {
fs.accessSync(this.editorRootPath, fs.constants.W_OK);
} catch (error) {
return;
}

// ensure metadata.hub.json exists and has a productName entry
const hubMetaDataPath = path.join(this.editorRootPath, 'metadata.hub.json');
if (!fs.existsSync(hubMetaDataPath)) {
const metadata = {
Expand Down
6 changes: 4 additions & 2 deletions src/unity-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,12 @@ wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | tee /usr/
echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list
echo "deb https://archive.ubuntu.com/ubuntu jammy main universe" | tee /etc/apt/sources.list.d/jammy.list
apt-get update
apt-get install -y --no-install-recommends unityhub ffmpeg libgtk2.0-0 libglu1-mesa libgconf-2-4 libncurses5
apt-get install -y --no-install-recommends unityhub=3.14.3 ffmpeg libgtk2.0-0 libglu1-mesa libgconf-2-4 libncurses5
apt-get clean
sed -i 's/^\\(.*DISPLAY=:.*XAUTHORITY=.*\\)\\( "\\$@" \\)2>&1$/\\1\\2/' /usr/bin/xvfb-run
printf '#!/bin/bash\nxvfb-run --auto-servernum /opt/unityhub/unityhub "$@" 2>/dev/null' | tee /usr/bin/unity-hub >/dev/null
chmod 777 /usr/bin/unity-hub
which unityhub || { echo "Unity Hub installation failed"; exit 1; }
hubPath=$(which unityhub)

if [ -z "$hubPath" ]; then
Expand All @@ -432,7 +433,8 @@ chmod -R 777 "$hubPath"`]);
}

await fs.promises.access(this.executable, fs.constants.X_OK);
this.logger.debug(`Unity Hub install complete`);
const installedVersion = await this.getInstalledHubVersion();
this.logger.info(`Unity Hub ${installedVersion} installed successfully.`);
}

private async getInstalledHubVersion(): Promise<SemVer> {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export async function Exec(command: string, args: string[], options: ExecOptions
}

if (exitCode !== 0) {
throw new Error(`${command} failed with exit code ${exitCode}`);
throw new Error(`${command} failed with exit code ${exitCode}\n${output}`);
}
}

Expand Down
Loading