Header image

Automating your Unity WebGL export on Github

posted by pschichtel | 06 May 2021

We at Banana4Life develop our games on Linux. Unity on Linux most of the time works fairly well, but every now and then we have some issues during the WebGL export. This time the export kept failing due to an incompatible python version on our systems.

Instead of looking into how to fix the export on our systems I started looking into ways to export the game using a containerized version of Unity. It doesn't take long to find the Game CI project and eventually Unity's official docker containers.

When using the containerized version of Unity, you still need a license file for it to start. If you are a free user of Unity, which I'm guessing is probably most of you, you can either take the file from your local installation or use the manual activation process. Try not get too confused about all the different "howto" guides for building your project with Unity's CLI, most of them are probably outdated. Stick to the official Unity documention, it covers all the options pretty well.

Building locally in container, while working perfectly fine, was suddenly not enough for me anymore and I started looking into building the export and deploying the WebGL version using Github actions. Luckily the GameCI project also built a ready made Github action that is pretty well documented: https://game.ci/docs/github/builder.

If previously blogged about how we deploy our games: here and here. So we simply create an orphaned branch for gh-pages and put the jam submissions into separate folders in there. Likely, there is an action for that as well.

So with this workflow on Github we now have a fully automated build and deployment of the WebGL version of our game within 10-15 minutes after the push to Github. This almost feels like cheating.