Skip to content

Commit a872824

Browse files
- Enhanced error messages to include command output for failed executions - Added write permission verification before metadata file operations - Added `hub-install --hub-version <version>` argument to install a specific version of Unity Hub
1 parent 16fb618 commit a872824

File tree

10 files changed

+326
-77
lines changed

10 files changed

+326
-77
lines changed

.github/workflows/build-options.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"6000.2"
1919
],
2020
"include": [
21+
{
22+
"os": "ubuntu-latest",
23+
"unity-version": "none"
24+
},
2125
{
2226
"os": "ubuntu-latest",
2327
"build-target": "StandaloneLinux64"
@@ -31,10 +35,18 @@
3135
"os": "ubuntu-latest",
3236
"build-target": "Android"
3337
},
38+
{
39+
"os": "windows-latest",
40+
"unity-version": "none"
41+
},
3442
{
3543
"os": "windows-latest",
3644
"build-target": "StandaloneWindows64"
3745
},
46+
{
47+
"os": "macos-latest",
48+
"unity-version": "none"
49+
},
3850
{
3951
"os": "windows-latest",
4052
"build-target": "Android"

.github/workflows/unity-build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ jobs:
4747
shell: bash
4848
timeout-minutes: 30
4949
run: |
50+
unity-cli hub-install --hub-version 3.12.0
5051
unity-cli hub-install --auto-update
51-
unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-target }}" --json
52+
if [ "${{ matrix.unity-version }}" != "none" ]; then
53+
unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-target }}" --json
54+
fi
5255
- name: Verify UNITY_HUB_PATH and UNITY_EDITOR_PATH variables
5356
shell: bash
5457
run: |
@@ -61,20 +64,23 @@ jobs:
6164
exit 1
6265
fi
6366
64-
if [ -z "${UNITY_EDITOR_PATH}" ]; then
67+
if [ "${{ matrix.unity-version }}" != "none" ] && [ -z "${UNITY_EDITOR_PATH}" ]; then
6568
echo "Error: UNITY_EDITOR_PATH is not set"
6669
exit 1
6770
fi
6871
- name: Activate License
72+
if : ${{ matrix.unity-version != 'none' }}
6973
shell: bash
7074
run: |
7175
unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
7276
- name: Create Unity Project
77+
if : ${{ matrix.unity-version != 'none' }}
7378
shell: bash
7479
run: |
7580
unity-cli list-project-templates --unity-editor "${UNITY_EDITOR_PATH}" --json
7681
unity-cli create-project --name "Unity Project" --unity-editor "${UNITY_EDITOR_PATH}" --json
7782
- name: Verify UNITY_PROJECT_PATH variable
83+
if : ${{ matrix.unity-version != 'none' }}
7884
shell: bash
7985
run: |
8086
if [ -z "${UNITY_PROJECT_PATH}" ]; then
@@ -119,6 +125,7 @@ jobs:
119125
unity-cli run --log-name Validate -quit -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset
120126
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 }}
121127
- name: Uninstall Editor
128+
if: ${{ matrix.unity-version != 'none' }}
122129
shell: bash
123130
run: |
124131
if [ -z "${UNITY_EDITOR_PATH}" ]; then

README.md

Lines changed: 205 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@
44

55
A powerful command line utility for the Unity Game Engine. Automate Unity project setup, editor installation, license management, building, and more—ideal for CI/CD pipelines and developer workflows.
66

7+
## Table of Contents
8+
9+
- [Features](#features)
10+
- [Installation](#installation)
11+
- [Usage](#usage)
12+
- [Common Commands](#common-commands)
13+
- [Auth](#auth)
14+
- [License Version](#license-version)
15+
- [Activate License](#activate-license)
16+
- [Return License](#return-license)
17+
- [Unity Hub](#unity-hub)
18+
- [Hub Version](#hub-version)
19+
- [Hub Path](#hub-path)
20+
- [Unity Hub Install](#unity-hub-install)
21+
- [Run Unity Hub Commands](#run-unity-hub-commands)
22+
- [Unity Editor](#unity-editor)
23+
- [Setup Unity Editor](#setup-unity-editor)
24+
- [Uninstall Unity Editor](#uninstall-unity-editor)
25+
- [List Project Templates](#list-project-templates)
26+
- [Create Unity Project](#create-unity-project)
27+
- [Open Unity Project](#open-unity-project)
28+
- [Run Unity Editor Commands](#run-unity-editor-commands)
29+
- [Unity Package Manager](#unity-package-manager)
30+
- [Sign a Unity Package](#sign-a-unity-package)
31+
732
## Features
833

934
- Install and manage Unity Hub and Unity Editors (multi-platform)
@@ -32,59 +57,190 @@ With options always using double dashes (`--option`) and arguments passed direct
3257

3358
### Common Commands
3459

60+
- `unity-cli --help` for a full list of commands and options.
61+
- `unity-cli [command] --help` for details on a specific command.
62+
- `unity-cli [command] --json` to get the output in JSON format (if supported).
63+
- `unity-cli [command] --verbose` to enable verbose logging for debugging.
64+
65+
```bash
66+
unity-cli --help
67+
```
68+
3569
#### Auth
3670

37-
- `unity-cli license-version`: Print the Unity License Client version.
38-
- `unity-cli activate-license [options]`: Activate a Unity license.
39-
- `unity-cli return-license [options]`: Return a Unity license.
71+
##### License Version
72+
73+
`license-version`: Print the Unity License Client version.
74+
75+
```bash
76+
unity-cli license-version
77+
```
78+
79+
##### Activate License
80+
81+
`activate-license [options]`: Activate a Unity license.
82+
83+
- `-l`, `--license`: License type (personal, professional, floating). Required.
84+
- `-e`, `--email`: Email associated with the Unity account. Required when activating a personal or professional license.
85+
- `-p`, `--password`: Password for the Unity account. Required when activating a personal or professional license.
86+
- `-s`, `--serial`: License serial number. Required when activating a professional license.
87+
- `-c`, `--config`: Path to the configuration file, or base64 encoded JSON string. Required when activating a floating license.
88+
- `--verbose`: Enable verbose output.
89+
90+
```bash
91+
unity-cli activate-license --license personal --email <your-email> --password <your-password>
92+
```
93+
94+
##### Return License
95+
96+
`return-license [options]`: Return a Unity license.
97+
98+
- `-l`, `--license`: License type (personal, professional, floating)
99+
- `--verbose`: Enable verbose output.
100+
101+
```bash
102+
unity-cli return-license --license personal
103+
```
40104

41105
#### Unity Hub
42106

43-
- `unity-cli hub-version`: Print the Unity Hub version.
44-
- `unity-cli hub-install [options]`: Install or update the Unity Hub.
45-
- `unity-cli hub-path`: Print the Unity Hub executable path.
46-
- `unity-cli hub [options] <args...>`: Run Unity Hub command line arguments (passes args directly to the hub executable).
107+
##### Hub Version
47108

48-
#### Unity Editor
109+
`hub-version`: Print the Unity Hub version.
110+
111+
```bash
112+
unity-cli hub-version
113+
```
49114

50-
- `unity-cli setup-unity [options]`: Find or install the Unity Editor for a project or specific version.
51-
- `unity-cli uninstall-unity [options]`: Uninstall a Unity Editor version.
52-
- `unity-cli list-project-templates [options]`: List available Unity project templates for an editor.
53-
- `unity-cli create-project [options]`: Create a new Unity project from a template.
54-
- `unity-cli open-project [options]`: Open a Unity project in the Unity Editor.
55-
- `unity-cli run [options] <args...>`: Run Unity Editor command line arguments (passes args directly to the editor).
115+
##### Hub Path
56116

57-
#### Unity Package Manager
117+
`hub-path`: Print the Unity Hub executable path.
58118

59-
- `unity-cli sign-package [options]`: Sign a Unity package for distribution.
119+
```bash
120+
unity-cli hub-path
121+
```
60122

61-
Run `unity-cli --help` for a full list of commands and options.
123+
##### Unity Hub Install
62124

63-
#### Install Unity Hub and Editor
125+
`hub-install [options]`: Install or update the Unity Hub
126+
127+
- `--auto-update`: Automatically updates the Unity Hub if it is already installed. Cannot be used with --hub-version.
128+
- `--hub-version`: Specify to install a specific version of Unity Hub. Cannot be used with --auto-update.
129+
- `--verbose`: Enable verbose output.
130+
- `--json`: Output installation information in JSON format.
64131

65132
```bash
66133
unity-cli hub-install
67-
unity-cli setup-unity --unity-version 2022.3.x --modules android,ios
68134
```
69135

70-
#### Activate a Unity License
136+
##### Run Unity Hub Commands
137+
138+
`hub [options] <args...>`: Run Unity Hub command line arguments (passes args directly to the hub executable).
139+
140+
- `<args...>`: Arguments to pass directly to the Unity Hub executable.
141+
- `--verbose`: Enable verbose output.
71142

72-
Supports personal, professional, and floating licenses (using a license server configuration).
143+
Lists available Unity Hub commands:
73144

74145
```bash
75-
unity-cli activate-license --license personal --email <your-email> --password <your-password>
146+
unity-cli hub help
76147
```
77148

78-
#### Create a New Project from a Template
149+
Gets a list of installed editors:
150+
151+
```bash
152+
unity-cli hub editors --installed
153+
```
154+
155+
#### Unity Editor
156+
157+
##### Setup Unity Editor
158+
159+
`setup-unity [options]`: Find or install the Unity Editor for a project or specific version.
160+
161+
- `-p`, `--unity-project <unityProject>` The path to a Unity project or `none` to skip project detection.
162+
- `-u`, `--unity-version <unityVersion>` The Unity version to get (e.g. `2020.3.1f1`, `2021.x`, `2022.1.*`, `6000`). If specified, it will override the version read from the project.
163+
- `-c`, `--changeset <changeset>` The Unity changeset to get (e.g. `1234567890ab`).
164+
- `-a`, `--arch <arch>` The Unity architecture to get (e.g. `x86_64`, `arm64`). Defaults to the architecture of the current process.
165+
- `-b`, `--build-targets <buildTargets>` The Unity build target to get (e.g. `iOS,Android`).
166+
- `-m`, `--modules <modules>` The Unity module to get (e.g. ios, android).
167+
- `-i`, `--install-path <installPath>` The path to install the Unity Editor to. By default, it will be installed to the default Unity Hub location.
168+
- `--verbose` Enable verbose logging.
169+
- `--json` Prints the last line of output as JSON string.
170+
171+
Installs the latest Unity 6 version with Android and iOS modules:
172+
173+
```bash
174+
unity-cli setup-unity --unity-version 6000 --modules android,ios
175+
```
176+
177+
##### Uninstall Unity Editor
178+
179+
`uninstall-unity [options]`: Uninstall a Unity Editor version.
180+
181+
- `-e`, `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `-u`, `--unity-version` or the `UNITY_EDITOR_PATH` environment variable must be set.
182+
- `-u`, `--unity-version <unityVersion>` The Unity version to get (e.g. `2020.3.1f1`, `2021.x`, `2022.1.*`, `6000`). If unspecified, then `--unity-editor` must be specified.
183+
- `-c`, `--changeset <changeset>` The Unity changeset to get (e.g. `1234567890ab`).
184+
- `-a`, `--arch <arch>` The Unity architecture to get (e.g. `x86_64`, `arm64`). Defaults to the architecture of the current process.
185+
- `--verbose` Enable verbose logging.
186+
187+
```bash
188+
unity-cli uninstall-unity --unity-version 6000
189+
```
190+
191+
##### List Project Templates
79192

80193
> [!NOTE]
81194
> Regex patterns are supported for the `--template` option. For example, to create a 3D project with either the standard or cross-platform template, you can use `com.unity.template.3d(-cross-platform)?`.
82195
196+
`list-project-templates [options]`: List available Unity project templates for an editor.
197+
198+
- `-e`, `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `-u`, `--unity-version` or the `UNITY_EDITOR_PATH` environment variable must be set.
199+
- `-u`, `--unity-version <unityVersion>` The Unity version to get (e.g. `2020.3.1f1`, `2021.x`, `2022.1.*`, `6000`). If unspecified, then `--unity-editor` must be specified.
200+
- `-c`, `--changeset <changeset>` The Unity changeset to get (e.g. `1234567890ab`).
201+
- `-a`, `--arch <arch>` The Unity architecture to get (e.g. `x86_64`, `arm64`). Defaults to the architecture of the current process.
202+
- `--verbose` Enable verbose logging.
203+
- `--json` Prints the last line of output as JSON string.
204+
205+
Lists available project templates for Unity 6:
206+
83207
```bash
84-
unity-cli create-project --name "MyGame" --template com.unity.template.3d(-cross-platform)? --unity-editor <path-to-editor>
208+
unity-cli list-project-templates --unity-version 6000
85209
```
86210

87-
#### Open a project from the command line
211+
##### Create Unity Project
212+
213+
`create-project [options]`: Create a new Unity project from a template.
214+
215+
- `-n`, `--name <projectName>` The name of the new Unity project. If unspecified, the project will be created in the specified path or the current working directory.
216+
- `-p`, `--path <projectPath>` The path to create the new Unity project. If unspecified, the current working directory will be used.
217+
- `-t`, `--template <projectTemplate>` The name of the template package to use for creating the unity project. Supports regex patterns. (default:
218+
`com.unity.template.3d(-cross-platform)?`)
219+
- `-u`, `--unity-version <unityVersion>` The Unity version to get (e.g. `2020.3.1f1`, `2021.x`, `2022.1.*`, `6000`). If unspecified, then `--unity-editor` must be specified.
220+
- `-e`, `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `-u`, `--unity-version`, or the `UNITY_EDITOR_PATH` environment variable must be set.
221+
- `--verbose` Enable verbose logging.
222+
- `--json` Prints the last line of output as JSON string.
223+
224+
Creates a new Unity project named "MyGame" using the latest version of Unity 6 and the 3D template:
225+
226+
```bash
227+
unity-cli create-project --name "MyGame" --template com.unity.template.3d(-cross-platform)? --unity-version 6000
228+
```
229+
230+
##### Open Unity Project
231+
232+
`open-project [options]`: Open a Unity project in the Unity Editor.
233+
234+
- `-p`, `--unity-project <unityProject>` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable or the current working directory will be used.
235+
- `-u`, `--unity-version <unityVersion>` The Unity version to get (e.g. `2020.3.1f1`, `2021.x`, `2022.1.*`, `6000`). If specified, it will override the version read from the project.
236+
- `-t`, `--build-target <buildTarget>` The Unity build target to switch the project to (e.g. `StandaloneWindows64`, `StandaloneOSX`, `iOS`, `Android`, etc).
237+
- `--verbose` Enable verbose logging.
238+
239+
Opens a specific Unity project with the latest Unity 6 version:
240+
241+
```bash
242+
unity-cli open-project --unity-project <path-to-project> --unity-version 6000
243+
```
88244

89245
> [!TIP]
90246
> If you run this command in the same directory as your Unity project, you can omit the `--unity-project`, `--unity-version`, and `--unity-editor` options.
@@ -93,13 +249,35 @@ unity-cli create-project --name "MyGame" --template com.unity.template.3d(-cross
93249
unity-cli open-project
94250
```
95251

96-
#### Build a Project
252+
##### Run Unity Editor Commands
253+
254+
`run [options] <args...>`: Run Unity Editor command line arguments (passes args directly to the editor).
255+
256+
- `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `--unity-project` or the `UNITY_EDITOR_PATH` environment variable must be set.
257+
- `--unity-project <unityProject>` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable will be used, otherwise no project will be specified.
258+
- `--log-name <logName>` The name of the log file.
259+
- `<args...>` Arguments to pass directly to the Unity Editor executable.
260+
- `--verbose` Enable verbose logging.
97261

98262
```bash
99263
unity-cli run --unity-project <path-to-project> -quit -batchmode -executeMethod StartCommandLineBuild
100264
```
101265

102-
#### Sign a Unity Package
266+
#### Unity Package Manager
267+
268+
##### Sign a Unity Package
269+
270+
> [!WARNING]
271+
> This command feature is in beta and may change in future releases.
272+
273+
`sign-package [options]`: Sign a Unity package for distribution.
274+
275+
- `--package <package>` Required. The fully qualified path to the folder that contains the package.json file for the package you want to sign. Note: Don’t include package.json in this parameter value.
276+
- `--output <output>` Optional. The output directory where you want to save the signed tarball file (.tgz). If unspecified, the package contents will be updated in place with the signed .attestation.p7m file.
277+
- `--email <email>` Email associated with the Unity account. If unspecified, the `UNITY_USERNAME` environment variable will be used.
278+
- `--password <password>` The password of the Unity account. If unspecified, the `UNITY_PASSWORD` environment variable will be used.
279+
- `--organization <organization>` The Organization ID you copied from the Unity Cloud Dashboard. If unspecified, the `UNITY_ORGANIZATION_ID` environment variable will be used.
280+
- `--verbose` Enable verbose logging.
103281

104282
> [!NOTE]
105283
> The `--output` option is optional. If not specified, the package contents will be updated in place with the signed `.attestation.p7m` file. Otherwise a signed `.tgz` file will be created in the specified output directory.

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": "@rage-against-the-pixel/unity-cli",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

0 commit comments

Comments
 (0)