In this article, I will explain how you get Unity builds with Github Actions. End of this example, We will get an aab
file for Android.
We will use GameCI's Builder action, but we need Unity's license file for using Builder action so, we will use GameCI' Activate action.
Setting Up Unity Activate
First of all we create a folder with .github
name under the root directory, then create workflows
folder under this. We make an activation.yml
file for preparing license file.
name: Acquire activation file
on:
workflow_dispatch:
jobs:
activation:
name: Request manual activation file 🔑
runs-on: ubuntu-latest
steps:
# Request manual activation file
- name: Request manual activation file
id: getManualLicenseFile
uses: game-ci/unity-request-activation-file@v2
with:
unityVersion: "2018.4.12f1"
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }}
Our activation file will be look like above.
workflow_dispatch
defines our workflow is triggered manually. unityVersion
defines which Unity version will we use.
When we run this action Github provides us a file with Unity_vxx.alf
extension. We upload this file to license.unity3d.com, then follow instructions. Unity gives us a file with Unity_Vx.ulf
extension. We create a secret with UNITY_LICENSE
key and set its value with the file's content which Unity provided us.
Now we can proceed to build process.
Getting Unity Build
For build process, we create a main.yml
file under the workflows folder.
name: Build Project
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
buildForAllSupportedPlatforms:
name: Build for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
targetPlatform:
- Android # Build an Android .apk standalone app.
projectPath:
- "Color Blocks"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v2
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
projectPath: ${{ matrix.projectPath }}
unityVersion: "2018.4.12f1"
androidAppBundle: true
androidKeystoreName: user.keystore
androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}
- uses: actions/upload-artifact@v2
with:
name: Build-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
Our main.yml
file looks like above.
We trigger our workflow when we release a new tag, or manually thanks to workflow_dispatch
and push:tags
.
In the beginning, I indicated, we will get an .aab
file, so we set androidAppBundle
field true. We store our keystore informations which created by Unity as secrets for signing our aab
file.
Also, GameCI's android and iOS actions are available for deploying Unity builds to Google Play and App Store automatically.
Github will build our Unity project when we release a new tag or by manually.
Don't forget to check it out my game Color Blocks .
Sources: