Game
Tales of Kulplex
5 years ago

Tales of Kulplex, Devlog #9 - Powering Up Your Unity Game Development with DevOps: Docker + GitLab + Discord


Some days ago, as I was watching some of the latest remote GDC talks, I stumbled upon an interesting video titled “Stress-Free Game Development: Powering Up Your Studio With DevOps” (link).

The talk is about how DevOps can make new releases and updates stress-free by automating work, standardising collaboration and minimizing errors, which all contribute to avoid the infamous “crunch”.

Already from the first few minutes, I knew I would love it; I also knew it would undoubtedly send me down a rabbit-hole of implementing some of the presented techniques.

I was right in both cases, as the talk spurred me on to improve my own deployment system even further, and this is why I am turning my experiences into this devlog.

My First Build System

My first build system was a set of tools that I created in Unity as an Editor Window.

I wanted to automatically create, review and save changelogs depending on the latest commit messages. The way I was doing this initially was quite time consuming, as I needed to go through each commit message and manually decide whether it was worthy of being in a changelog:

screen_shot_2020-04-24_at_133825.png

So, I created a small tab in the Unity Editor which automatically picks all the latest commit messages and I can easily review them and delete any that are not needed.
On top of that, I also thought of creating a flexible template, so I can easily change the final look of the changelog:

image.png

Next, I wanted to click a button, walk away, and have Unity go through all the platforms and make different builds for me.
It doesn't take too long to build for a specific platform (e.g. Windows) but if you need to create them for multiple ones, it will need to re-import the whole project over and over again.

For this, I created yet another tab, to help me build for a specific platform or just all of them sequentially:

image.png

This system also automatically performed the following steps:

  • Tagging the last commit with the current game version (this helps with knowing where a changelog should stop)

  • Pushing to our own Discord store for testing

  • Sending progress updates and changelog to a specific Discord channel

This had been enough for me, but the talk made me realize that there was much more to be improved. For example:

  • My development would stop for roughly 1 hour of building, as Unity cannot be used during that time.

  • At the end of every build, I would have to switch back from the latest platform and re-import everything again

Both of these points made me build much less often than I could, simply because I didn’t want to wait for the build to finish to keep working.

What if I could trigger the build, turn off the computer, go to bed and find everything done?
Or even better, what if I could trigger the build and continue working as nothing happened?

This is how I had the idea for the “Trigger Remote Build” button!

screen_shot_2020-04-22_at_163425.png

To achieve that, as it turned out, I required much more than just an Editor Window - I needed another machine used solely for making builds.

Moving to a Build Server

Researching how to accomplish this task, I realized that I needed another machine that can be used only for making builds.

I have a personal server that I use for different purposes: off-site backup, git repositories, dropbox, etc. It’s just a very simple machine with Ubuntu running on it, but I especially love it because it was just an old laptop with a broken screen sitting inside a box before I turned it into a multi-purpose server.
Since it was already running, it was a no-brainer to add another task for it to perform.

A spare working laptop is not something everyone has available, so if I had to achieve the same goal without it, I would probably do one of the following:

  • Rent a cheap Virtual Private Server (VPS) [some even go for $5/mo]

  • Rent the aforementioned server with a friend and share the costs! [Don't put anything vital there as you never know if your friend will explode the server one day ]

  • Find any relative with an overly powerful computer and sweet-talk them into letting you use it for "work" (this requires networking skills and high charisma points)

On the other hand, using something like RaspberryPi will not help with automating Unity builds (unsupported and will take maybe weeks).

Time to Jump into Action

Without further ado, here’s how you can transform a server into an automated build system for your Unity projects:

Simple/Quick:

  • Install Git (docs)

  • Clone your project (if you are not using git already, do it now! (docs)

  • Setup Unity3D-CI (repo)

  • Create trigger_build.sh script for automated build (gist)

    • (Optional) Message to Discord on completion (gist)

  • Run script!

This “simple” setup is pretty nice: it makes use of Docker to spin up a tiny virtual machine, which just requires you to activate the Unity license, and then you have a small computer doing the job for you via script.

Advanced Build Server: Turning it up to 11

The simple method works pretty well, but I wasn’t fully satisfied. It still required me to manually upload the builds to Discord whenever they are completed.
I wanted to be able to trigger the build whenever I pushed a certain tag on my GitLab, automatically deploy to our internal Discord store and send the current changelog, just as my first setup did.

So, here is the more complex, and honestly mental, setup to achieve just that. Ready? Go!

Note: I am using GitLab for my git repository and pushing to Discord. That’s not a very common setup, so I put this mainly for posterity or for anyone who happens to have something similar. (Heyo there!)

GitLab CI + Discord /Dispatch + Changelog:

  • Same as Simple

  • Install GitLab runner (docs)

    • If you are self-hosted and using LetsEncrypt, you might have problems running the runner, this script solved it (gist)

  • Setup Runner on your GitLab project (docs)

    • Make sure the runner is alive and working on your project (they can get stuck for tons of reasons)

  • Install Dispatch (docs)

    • (As of April 2020) If you are getting panic errors, it’s due to some old OpenSSL implementation, use this executable instead (from official Dispatch discord): Fixed Dispatch for Linux

  • Setup the credentials for your Build System (gist)

    • And save it in ~/.dispatch/credentials.json, this will prevent the application to ask for login when publishing

  • Make script to Publish builds to Discord (docs)

  • (Optional) Fetch commits since current tag (gist)

    • This changelog can be used directly in the Discord message or filtered/parsed accordingly

  • Add new scripts to trigger_builds.sh to be executed after the builds are completed (gist)

  • Push a new commit with a tag to the repository to trigger everything!

  • Enjoy

screen_shot_2020-04-23_at_004331.png

Conclusion

DevOps is a set of practices that are used quite extensively nowadays in many fields of IT: web development being one of the forerunners, since updating a website is usually quick and invisible.

Having worked outside the game industry for quite some time, I often wonder why it seems harder to bring certain widespread concepts into game development.

Clearly, it’s sometimes due to the limited availability of technology, and whether your chosen engine or framework supports certain features. Other times, it’s due to higher difficulty projects, like the automated testing of a game. More often than not, though, I think it’s due to the fact that people believe that that’s just how everyone does it.

That’s why I advise you, if you are a game developer, to watch this video (link) and think of how you can do more automated work and less manual work. Even small things can make a big impact!

As a side note: working on servers without GUI and running scripts might feel frightening at first, but don’t worry!
Just pick up some old laptop (most people throw away their laptops when the screen or monitor are dead but other than that they are perfect as a server) and play around with it. Worst case scenario, you reinstall everything and start from scratch with more knowledge than before (that has more chance to happen if you choose to share it with the friend from before)!


We are looking for Pre-Alpha testers, join us on Discord:
https://discord.me/talesofkulplex

You can also stay in touch with us by following us on:

- Instagram: https://instagram.com/talesofkulplex

- Facebook: https://www.facebook.com/talesofkulplex

- Twitter: https://twitter.com/talesofkulplex

If you have any question, leave a comment!

Stay safe :)

Nesh



0 comments

Loading...

Next up

So

i may or may not make an full art of some person or i may just leave this like that-

Smile! Here, take some happy pills! ✨💊 #Blender #3DModelling #3DArt Buy me a Ko-fi: https://ko-fi.com/barbarafb_

"Thanks guys for endless hours of fun." 👍

(My first fan art. Read the article, please.)

#sonic #mario #photoshop

Shadow The Hedgehog X pixel art

Quantum precognition is one of the most powerful cards. End game cards & equipment. Demo/alpha build boss is no match for this deck.

Today I tackled drawing different variations of facial expressions for one of the main characters in Eden. What do you think of it? :) Eden: https://gamejolt.com/games/Eden/592698

If you have more of an acquired taste, the restaurants in Niravasi have you covered! Maybe skip the salad bar, though.

Only true badasses may pass! #conceptart #art #gamedesign

We're knee deep in multiple large features and "game feel". Quick peek behind the scenes in this weeks Dev Blog: https://bit.ly/2QmmaQM