As for most of my projects, I would like to get the CI process ready as soon as possible to enforce the best practices from the beginning. And a big shout out to the Unity community, who created GitHub Actions plugin - game-ci/unity-actions, that makes CI possible in Github Actions.
Before we set up the CI process, we need to perform a one-time action to get the Unity License. Here are the steps for acquiring Unity License for Github Actions.
Create a file .github/workflows/activation.yml
and add the following codes:
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
# Upload artifact (Unity_v20XX.X.XXXX.alf)
- name: Expose as artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }}
Commit and push the workflow to your Github repository, go to Github > Your Repository > Actions > Acquire activation file
. Then, click on the Run workflow
.
Once the workflow has run successfully, go to Github > Your Repository > Actions > Acquire activation file
and click on the first successful build. You will find an artefact at the bottom of the page, then save the file locally.
You need to go to license.unity3d.com and upload the activation file from the previous step. Complete the steps on the page, and you can download the license file (Unity_v20XX.x.ulf). Do not worry if the version does not exactly match your Unity Editor.
Once you get the file, you need to set the secrets in your repository for your Unity 3D CI workflow. Go to Github > Your Repository > Secrets
and add the following secrets:
UNITY_LICENSE - (Copy the contents of your license file into here)
UNITY_EMAIL - (Add the email address that you use to login to Unity)
UNITY_PASSWORD - (Add the password that you use to login to Unity)
Congratulations, now you can start to set up your workflow for building your Unity 3D games.
Copyright © 2024 Tek Min Ewe