Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
47175a0
unity-cli@v1.0.0
StephenHodgson Sep 15, 2025
603e5dc
setup basic cli scaffolding and unit tests
StephenHodgson Sep 15, 2025
a5bbd90
removed comment
StephenHodgson Sep 15, 2025
6f1a1f4
update .npmignore
StephenHodgson Sep 15, 2025
820809d
update .npmignore
StephenHodgson Sep 15, 2025
016865f
update .npmignore
StephenHodgson Sep 15, 2025
c9b4d9f
added license-client
StephenHodgson Sep 17, 2025
d1b3e50
formatting
StephenHodgson Sep 17, 2025
19b7260
fix terminal prompts
StephenHodgson Sep 17, 2025
b574bbc
add short args
StephenHodgson Sep 17, 2025
161e73e
implement unity hub installation
StephenHodgson Sep 17, 2025
1d1bf72
added unity hub installer and editor installer options
StephenHodgson Sep 18, 2025
addcea9
tweaks
StephenHodgson Sep 18, 2025
3a46459
add unity-project
StephenHodgson Sep 19, 2025
802ac3e
update unit tests
StephenHodgson Sep 19, 2025
0ff05be
update package name to include namespace
StephenHodgson Sep 19, 2025
007eea4
fix namespace
StephenHodgson Sep 19, 2025
7fb4068
updated trace logging
StephenHodgson Sep 19, 2025
768e5f8
cleanup and refactoring
StephenHodgson Sep 19, 2025
172ce95
added ci logging option
StephenHodgson Sep 19, 2025
742df69
add simple test workflow
StephenHodgson Sep 25, 2025
8453e55
use bash shell
StephenHodgson Sep 25, 2025
e6cf0c1
set -xe
StephenHodgson Sep 25, 2025
1638110
update packages
StephenHodgson Sep 25, 2025
acd300c
which sudo
StephenHodgson Sep 25, 2025
7b5ab95
get temp dir for CI env
StephenHodgson Sep 25, 2025
0971ffc
inherit env?
StephenHodgson Sep 25, 2025
c7d31ca
revert
StephenHodgson Sep 25, 2025
31e8afe
chmod
StephenHodgson Sep 25, 2025
252b335
verify dir exists before downloading
StephenHodgson Sep 25, 2025
ff1df1a
update download file permissions
StephenHodgson Sep 25, 2025
ac62079
only check access if it is a full path
StephenHodgson Sep 25, 2025
7e2cfa2
remove access check in exec
StephenHodgson Sep 25, 2025
28246a3
quote string inputs
StephenHodgson Sep 25, 2025
3a994d3
install commands with 777
StephenHodgson Sep 25, 2025
833e805
revert
StephenHodgson Sep 25, 2025
bcf8599
use direct sudo commands
StephenHodgson Sep 25, 2025
4043086
use email
StephenHodgson Sep 25, 2025
d0b2ebb
update license input string
StephenHodgson Sep 25, 2025
1e07fa5
add license
StephenHodgson Sep 25, 2025
04dcceb
update return license
StephenHodgson Sep 25, 2025
aff9265
update exec logging
StephenHodgson Sep 25, 2025
9b27aec
rework logging for exec
StephenHodgson Sep 25, 2025
38ecdea
new lines
StephenHodgson Sep 25, 2025
5b334ba
EOL
StephenHodgson Sep 25, 2025
6d16dae
spit group lines
StephenHodgson Sep 25, 2025
53def9f
rework group
StephenHodgson Sep 25, 2025
74c0578
EOL
StephenHodgson Sep 25, 2025
40fb0c0
attempt to install unity version
StephenHodgson Sep 25, 2025
c58afe1
update macos hub installer
StephenHodgson Sep 25, 2025
60fd2d7
update hub permissions on install
StephenHodgson Sep 25, 2025
9fb1f8a
ignored lines
StephenHodgson Sep 25, 2025
7d72f5a
tweak hub stdout
StephenHodgson Sep 25, 2025
8886d8b
debug
StephenHodgson Sep 25, 2025
8680a11
re-work how we filter output lines
StephenHodgson Sep 25, 2025
676aa21
format
StephenHodgson Sep 25, 2025
944f2ba
fix debug lines
StephenHodgson Sep 25, 2025
4b82700
break
StephenHodgson Sep 25, 2025
91b42e4
enable debug
StephenHodgson Sep 25, 2025
4b4f7df
new lines instead of EOL
StephenHodgson Sep 26, 2025
60ad8a0
mask output for license client
StephenHodgson Sep 26, 2025
40fb914
mask serial
StephenHodgson Sep 26, 2025
f5924e3
cleanup
StephenHodgson Sep 26, 2025
effeccf
start
StephenHodgson Sep 26, 2025
5a7db92
try to setup unity project
StephenHodgson Sep 26, 2025
cb19468
tail last line
StephenHodgson Sep 26, 2025
cab5eb1
print output
StephenHodgson Sep 26, 2025
8998cd1
rework some internals for editor cli
StephenHodgson Sep 26, 2025
3ca241d
set a small timeout after download
StephenHodgson Sep 26, 2025
e9c3133
ignore if no child processes
StephenHodgson Sep 26, 2025
625213e
silence some outputs
StephenHodgson Sep 26, 2025
df44961
print json
StephenHodgson Sep 26, 2025
74503a4
update exec output logic
StephenHodgson Sep 26, 2025
51b1403
cleanup
StephenHodgson Sep 26, 2025
a70b5c5
cleanup
StephenHodgson Sep 26, 2025
5369938
group editor cli exec
StephenHodgson Sep 26, 2025
de7156b
line endings
StephenHodgson Sep 26, 2025
01375d4
build with node 22
StephenHodgson Sep 26, 2025
15a2ba2
add validate and build commands
StephenHodgson Sep 26, 2025
99b195e
cd
StephenHodgson Sep 26, 2025
b924991
tweak variables
StephenHodgson Sep 26, 2025
d4fc17c
rename input args
StephenHodgson Sep 26, 2025
0f94655
verbose
StephenHodgson Sep 26, 2025
130ca39
fix input arg names
StephenHodgson Sep 26, 2025
0ad0c5d
verify template arg
StephenHodgson Sep 26, 2025
632ac10
fix commands
StephenHodgson Sep 27, 2025
e9a6ef8
turn off verbose
StephenHodgson Sep 27, 2025
33320d5
log editor cli exec directly to stdout
StephenHodgson Sep 27, 2025
93586b2
cleaner install cancellatino
StephenHodgson Sep 27, 2025
c2ae6cf
add support for build targets and updated readme
StephenHodgson Sep 27, 2025
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @StephenHodgson
27 changes: 27 additions & 0 deletions .github/workflows/build-options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"os": [
"ubuntu-latest",
"windows-latest",
"macos-latest"
],
"unity-version": [
"2022.3.x",
"6000.0.x",
"6000.1.x",
"6000"
],
"include": [
{
"os": "ubuntu-latest",
"build-target": "StandaloneLinux64"
},
{
"os": "windows-latest",
"build-target": "StandaloneWindows64"
},
{
"os": "macos-latest",
"build-target": "StandaloneOSX"
}
]
}
42 changes: 42 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: tests
on:
push:
branches: ['main']
pull_request:
branches: ['*']
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
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
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .github/
- uses: RageAgainstThePixel/job-builder@v1
id: setup-jobs
with:
build-options: ./.github/workflows/build-options.json
group-by: 'unity-version'
outputs:
jobs: ${{ steps.setup-jobs.outputs.jobs }}
validate:
if: ${{ needs.setup.outputs.jobs }}
needs: setup
name: build ${{ matrix.jobs.name }}
permissions:
contents: read
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.jobs) }}
fail-fast: false
max-parallel: 1
secrets: inherit
uses: ./.github/workflows/unity-build.yml
with:
matrix: ${{ toJSON(matrix.jobs.matrix) }}
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish
on:
push:
branches: [main]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: "https://registry.npmjs.org"
- run: |
npm ci
npm run build
# check if the last release is the same as the current version
lastVersion=$(npm show @rage-against-the-pixel/unity-releases-api version)
version=$(node -p "require('./package.json').version")
if [ "$version" = "$lastVersion" ]; then
echo "No changes detected"
exit 0
fi
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/unity-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: unity-build
permissions:
contents: read
on:
workflow_call:
inputs:
matrix:
required: true
type: string
secrets:
UNITY_USERNAME:
required: true
UNITY_PASSWORD:
required: true
jobs:
build:
name: ${{ matrix.name }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: false
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
- name: unity-cli
shell: bash
run: |
set -xe
npm ci
npm run build
npm run link
unity-cli --version
unity-cli hub-install
unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
setup_output=$(unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-targets }}" --json)
unity_editor_path=$(echo "$setup_output" | tail -n 1 | jq -r '.UNITY_EDITOR')
echo "$unity_editor_path"
create_project_output=$(unity-cli create-project --name "Unity Project" --unity-editor "${unity_editor_path}" --json --verbose)
project_path=$(echo "$create_project_output" | tail -n 1 | jq -r '.UNITY_PROJECT_PATH')
echo "${project_path}"
npm install -g openupm-cli
cd "${project_path}"
openupm add com.utilities.buildpipeline
unity-cli run --unity-editor "${unity_editor_path}" --unity-project "${project_path}" --log-name Validate -quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset
unity-cli run --unity-editor "${unity_editor_path}" --unity-project "${project_path}" --log-name Build -quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity
- name: Post Run
if: always()
shell: bash
run: |
set -xe
unity-cli return-license --license personal
14 changes: 14 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git/
.github/
.idea/
.vscode/
src/
tests/
node_modules/
.env
.env.local
*.log
*.tsbuildinfo
tsconfig*.json
package-lock.json
jest.config.mjs
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# unity-cli
A command line utility for the Unity Game Engine

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.

## Features

- Install and manage Unity Hub and Unity Editors (multi-platform)
- Activate and return Unity licenses (personal, professional, floating)
- Create new Unity projects from templates
- Run Unity Editor commands and builds from the CLI
- Supports all modules, architectures, and build targets
- Works on Windows, macOS, and Linux
- Designed for automation and CI/CD

## Installation

```bash
npm install -g @rage-against-the-pixel/unity-cli
```

## Usage

```bash
unity-cli [command] [options]
```

### Common Commands

- `unity-cli hub-install`: Install Unity Hub
- `unity-cli hub-version`: Print Unity Hub version
- `unity-cli hub-path`: Print Unity Hub executable path
- `unity-cli hub [args...]`: Run Unity Hub commands directly
- `unity-cli activate-license`: Activate a Unity license
- `unity-cli return-license`: Return a Unity license
- `unity-cli license-version`: Print Unity License Client version
- `unity-cli setup-unity`: Find or install Unity Editor for a project/version
- `unity-cli create-project`: Create a new Unity project from a template
- `unity-cli run [args...]`: Run commands in [Unity Editor Command Line Arguments](https://docs.unity3d.com/Manual/EditorCommandLineArguments.html)

#### Install Unity Hub and Editor

```bash
unity-cli hub-install
unity-cli setup-unity --unity-version 2022.3.x --modules android,ios --json
```

#### Activate a Unity License

```bash
unity-cli activate-license --email <your-email> --password <your-password> --serial <your-serial>
```

#### Create a New Project from a Template

```bash
unity-cli create-project --name "MyGame" --template com.unity.template.3d --unity-editor <path-to-editor>
```

#### Build a Project

```bash
unity-cli run --unity-editor <path-to-editor> --unity-project <path-to-project> -quit -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild
```
9 changes: 9 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
roots: ['<rootDir>/tests'],
transform: {
'^.+\\.ts$': ['ts-jest', { useESM: true, tsconfig: '<rootDir>/tsconfig.jest.json' }],
},
testMatch: ['**/?(*.)+(test).ts'],
};
Loading
Loading