Setting up a GitHub Build Server
All the Reality Collective projects are all automated using self hosted runners on GitHub using GitHub actions. These make use of several reusable workflows to test, build and package all the projects.
To operate these and reduce costs we self host our own build servers which need to be setup accordingly, which the following guide details the setup process.
Software Requirements
- Unity Hub - plus clients
- Visual Studio - any edition (can just use the version installed with Unity)
- Node.js - the current LTS release (the Collective's workflows run on Node 22)
- PowerShell 7 - the current release, not only the Windows PowerShell 5.1 that ships with Windows 11
- .NET SDK - the current LTS release
- Java JRE 8+
- Git for Windows
- Github Runner client
- (optional) VSCode
Server setup process
For the main part, it is simply a case of getting all the software installed and registered in the following order:
- Install Node.js (current LTS), making sure to also opt in to the additional Chocolatey dependencies.
- Install PowerShell 7 to ensure all the paths and latest versions of the tools are installed.
- Install Git for Windows for all Git related operations got the Actions.
- Install the .NET SDK (current LTS), note it is the SDK for your platform, e.g. the 64bit client for most cases.
- Install the latest Java JRE 8+, required only for Android builds.
- Install the latest Unity Hub and all the latest client versions your builds require. (The automation scripts will auto-install Unity versions, but it can be unreliable, because Unity...)
- Optionally, you can also install VSCode which helps managing the environment and diagnosing any build issues on the server (plus its awesome)
GitHub runner setup
Once the environment is setup, you will need to install the GitHub Actions runners for either your Organisation or individual projects (the process is the same). Repeat the following process for each runner you want to setup (the Reality Collective has at least 6 runners setup on each machine for reference, just setup how many you need):
- Download the latest Github Runner client to the build server
- Important Create a new folder at the ROOT of a drive (preferably your fastest drive, e.g. ssd) with a single letter (keep it short). For example, we setup a folder called "g" (for GitHub)
- Extract the GitHub runner client to a folder in the new folder with the name of the runner you want to setup, e.g. "realitycollective-01"
- In a browser, navigate to the "Runners" configuration ofr your Organisation or Project under "Settings -> Actions -> Runners"
- Click on the "New runner" button which will take you to an instruction screen for setting up the runner
- Copy the command from the "Configure" section which includes the setup token for the runner (which identifies and authenticates the runner client), e.g.
./config.cmd --url https://github.com/realitycollective --token MYSECRETTOKEN
- On the build server, open a "Command Prompt" or "Terminal" window with Elevated Permissions (Run as administrator), e.g. "Start -> Run -> CMD -> Run as administrator"
- Navigate to the folder you extracted the GitHub runner to, e.g. "c:\g\realitycollective-01"
- Paste the command you copied (you might need to remove the "." from the command depending on the window you are using)
- Hit enter (:D)
- You will now be walked through several options to configure the runner.
- Hit Enter to accept the default "Runner Group" (unless you have GitHub Enterprise, you can only have a SINGLE runner group)
- Enter the name of the runner you want to configure, e.g. "realitycollective-01"
- Hit Enter to accept the default labels for your runner. This identify the capabilities of the Build environment, the defaults should be fine. (for more information, read about GitHub actions labels here)
- When prompted, enter "w" for the working folder, you can select the default _work, but better to keep folder lengths small.
- You will then be asked if you want to "Configure the Runner to run as a Service", if you want to, hit "Y" (we always run it as a service)
- When asked for the credentials, just hit Enter to accept the default, which is sufficient for most scenarios. If you need additional permissions, then look to creating a Service Account on the build server.
- This completes the runner setup.
If your projects are "Public" repositories and this is the first time setting up GitHub Runners, you will also need to configure your "Default Runner Setup" to be able to use Public repositories (by default, ONLY Private repos are allowed). Simply navigate back to the Runner Configuration on GitHub via "GitHub -> Settings -> Actions -> Runner Groups", click on the Default group and click the checkbox to "Allow public repositories"
Trouble shooting
One issue we occasionally run in to, is that Unity does not enable the default permissions for building Android projects, resulting in such errors as "Build failure, unable to update the SDK"
To resolve this, follow the instructions in this post to try and resolve the issue. FOr no reason, different fixes are needed at different times, but you only need to solve this once.