Skip to content

Commit 0878365

Browse files
unity-cli@v1.0.0 (#1)
- Hello World!
1 parent d608d5c commit 0878365

22 files changed

Lines changed: 8353 additions & 1 deletion

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @StephenHodgson
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"os": [
3+
"ubuntu-latest",
4+
"windows-latest",
5+
"macos-latest"
6+
],
7+
"unity-version": [
8+
"2022.3.x",
9+
"6000.0.x",
10+
"6000.1.x",
11+
"6000"
12+
],
13+
"include": [
14+
{
15+
"os": "ubuntu-latest",
16+
"build-target": "StandaloneLinux64"
17+
},
18+
{
19+
"os": "windows-latest",
20+
"build-target": "StandaloneWindows64"
21+
},
22+
{
23+
"os": "macos-latest",
24+
"build-target": "StandaloneOSX"
25+
}
26+
]
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: tests
2+
on:
3+
push:
4+
branches: ['main']
5+
pull_request:
6+
branches: ['*']
7+
types: [opened, reopened, synchronize, ready_for_review]
8+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
jobs:
13+
setup:
14+
if: github.event.pull_request.draft == false
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
sparse-checkout: .github/
22+
- uses: RageAgainstThePixel/job-builder@v1
23+
id: setup-jobs
24+
with:
25+
build-options: ./.github/workflows/build-options.json
26+
group-by: 'unity-version'
27+
outputs:
28+
jobs: ${{ steps.setup-jobs.outputs.jobs }}
29+
validate:
30+
if: ${{ needs.setup.outputs.jobs }}
31+
needs: setup
32+
name: build ${{ matrix.jobs.name }}
33+
permissions:
34+
contents: read
35+
strategy:
36+
matrix: ${{ fromJSON(needs.setup.outputs.jobs) }}
37+
fail-fast: false
38+
max-parallel: 1
39+
secrets: inherit
40+
uses: ./.github/workflows/unity-build.yml
41+
with:
42+
matrix: ${{ toJSON(matrix.jobs.matrix) }}

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
on:
3+
push:
4+
branches: [main]
5+
workflow_dispatch:
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 22.x
16+
registry-url: "https://registry.npmjs.org"
17+
- run: |
18+
npm ci
19+
npm run build
20+
# check if the last release is the same as the current version
21+
lastVersion=$(npm show @rage-against-the-pixel/unity-releases-api version)
22+
version=$(node -p "require('./package.json').version")
23+
if [ "$version" = "$lastVersion" ]; then
24+
echo "No changes detected"
25+
exit 0
26+
fi
27+
npm publish --access public
28+
env:
29+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/unity-build.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: unity-build
2+
permissions:
3+
contents: read
4+
on:
5+
workflow_call:
6+
inputs:
7+
matrix:
8+
required: true
9+
type: string
10+
secrets:
11+
UNITY_USERNAME:
12+
required: true
13+
UNITY_PASSWORD:
14+
required: true
15+
jobs:
16+
build:
17+
name: ${{ matrix.name }}
18+
strategy:
19+
matrix: ${{ fromJSON(inputs.matrix) }}
20+
fail-fast: false
21+
runs-on: ${{ matrix.os }}
22+
permissions:
23+
contents: read
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 22.x
29+
- name: unity-cli
30+
shell: bash
31+
run: |
32+
set -xe
33+
npm ci
34+
npm run build
35+
npm run link
36+
unity-cli --version
37+
unity-cli hub-install
38+
unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
39+
setup_output=$(unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-targets }}" --json)
40+
unity_editor_path=$(echo "$setup_output" | tail -n 1 | jq -r '.UNITY_EDITOR')
41+
echo "$unity_editor_path"
42+
create_project_output=$(unity-cli create-project --name "Unity Project" --unity-editor "${unity_editor_path}" --json --verbose)
43+
project_path=$(echo "$create_project_output" | tail -n 1 | jq -r '.UNITY_PROJECT_PATH')
44+
echo "${project_path}"
45+
npm install -g openupm-cli
46+
cd "${project_path}"
47+
openupm add com.utilities.buildpipeline
48+
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
49+
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
50+
- name: Post Run
51+
if: always()
52+
shell: bash
53+
run: |
54+
set -xe
55+
unity-cli return-license --license personal

.npmignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.git/
2+
.github/
3+
.idea/
4+
.vscode/
5+
src/
6+
tests/
7+
node_modules/
8+
.env
9+
.env.local
10+
*.log
11+
*.tsbuildinfo
12+
tsconfig*.json
13+
package-lock.json
14+
jest.config.mjs

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
11
# unity-cli
2-
A command line utility for the Unity Game Engine
2+
3+
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.
4+
5+
## Features
6+
7+
- Install and manage Unity Hub and Unity Editors (multi-platform)
8+
- Activate and return Unity licenses (personal, professional, floating)
9+
- Create new Unity projects from templates
10+
- Run Unity Editor commands and builds from the CLI
11+
- Supports all modules, architectures, and build targets
12+
- Works on Windows, macOS, and Linux
13+
- Designed for automation and CI/CD
14+
15+
## Installation
16+
17+
```bash
18+
npm install -g @rage-against-the-pixel/unity-cli
19+
```
20+
21+
## Usage
22+
23+
```bash
24+
unity-cli [command] [options]
25+
```
26+
27+
### Common Commands
28+
29+
- `unity-cli hub-install`: Install Unity Hub
30+
- `unity-cli hub-version`: Print Unity Hub version
31+
- `unity-cli hub-path`: Print Unity Hub executable path
32+
- `unity-cli hub [args...]`: Run Unity Hub commands directly
33+
- `unity-cli activate-license`: Activate a Unity license
34+
- `unity-cli return-license`: Return a Unity license
35+
- `unity-cli license-version`: Print Unity License Client version
36+
- `unity-cli setup-unity`: Find or install Unity Editor for a project/version
37+
- `unity-cli create-project`: Create a new Unity project from a template
38+
- `unity-cli run [args...]`: Run commands in [Unity Editor Command Line Arguments](https://docs.unity3d.com/Manual/EditorCommandLineArguments.html)
39+
40+
#### Install Unity Hub and Editor
41+
42+
```bash
43+
unity-cli hub-install
44+
unity-cli setup-unity --unity-version 2022.3.x --modules android,ios --json
45+
```
46+
47+
#### Activate a Unity License
48+
49+
```bash
50+
unity-cli activate-license --email <your-email> --password <your-password> --serial <your-serial>
51+
```
52+
53+
#### Create a New Project from a Template
54+
55+
```bash
56+
unity-cli create-project --name "MyGame" --template com.unity.template.3d --unity-editor <path-to-editor>
57+
```
58+
59+
#### Build a Project
60+
61+
```bash
62+
unity-cli run --unity-editor <path-to-editor> --unity-project <path-to-project> -quit -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild
63+
```

jest.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default {
2+
preset: 'ts-jest/presets/default-esm',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/tests'],
5+
transform: {
6+
'^.+\\.ts$': ['ts-jest', { useESM: true, tsconfig: '<rootDir>/tsconfig.jest.json' }],
7+
},
8+
testMatch: ['**/?(*.)+(test).ts'],
9+
};

0 commit comments

Comments
 (0)