GitHub Action to build Unity projects for different platforms.
Part of the Unity Actions collection.
Github Action to build Unity projects for different platforms.
It is recommended to run the Test action from the Unity Actions collection before running this action. This action also requires the Activation step.
See the Unity Actions collection repository for workflow documentation and reference implementation.
Create or edit the file called .github/workflows/main.yml
and add a job to it.
- uses: webbertakken/[email protected]
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
projectPath: path/to/your/project
unityVersion: 2020.X.XXXX
targetPlatform: WebGL
A complete workflow that builds every available platform could look like this:
name: Build project
on:
pull_request: {}
push: { branches: [master] }
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
jobs:
buildForSomePlatforms:
name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- path/to/your/project
unityVersion:
- 2019.2.11f1
- 2019.3.0f1
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
- StandaloneLinux64 # Build a Linux 64-bit standalone.
- iOS # Build an iOS player.
- Android # Build an Android .apk standalone app.
- WebGL # WebGL.
- WSAPlayer # Build an Windows Store Apps player.
- PS4 # Build a PS4 Standalone.
- XboxOne # Build a Xbox One Standalone.
- tvOS # Build to Apple's tvOS platform.
- Switch # Build a Nintendo Switch player.
steps:
- uses: actions/checkout@v1
- uses: webbertakken/[email protected]
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
- uses: actions/upload-artifact@v1
with:
name: Build
path: build
Notes:
- Don't forget to replace <test-project> with your project name.
- By default the enabled scenes from the project's settings will be built.
Below options can be specified under with:
for the unity-builder
action.
Specify the path to your Unity project to be built. The path should be relative to the root of your project.
required: false
default: <your project root>
Version of Unity to use for building the project.
required: false
default: 2019.2.1f11
Platform that the build should target.
Must be one of the allowed values listed in the Unity scripting manual.
required: true
Name of the build. Also the folder in which the build will be stored within buildsPath
.
required: false
default: <build_target>
Path where the builds should be stored.
In this folder a folder will be created for every targetPlatform.
required: false
default: build
Custom command to run your build.
There are two conditions for a custom buildCommand:
- Must reference a valid path to a
static
method. - The class must reside in the
Assets/Editor
directory.
example:
- uses: webbertakken/unity-builder@master
with:
buildMethod: EditorNamespace.BuilderClassName.StaticBulidMethod
required: false
default: Built-in script that will run a build out of the box.
Visit Unity Actions to find related actions for Unity.
Feel free to contribute.