UE4 automated client and server building with batch scripts
While working on Shotgo (working title) I have had to make builds quite regularly to test Steam API and multiplayer interactions. This can be quite tedious, especially if you also have to build and upload the server executable every time. To make this process easier I have written a simple batch script to automate the build process for me.
The batch script does not just create the client and server builds for me. It also zips the builds (using WinRAR CLI) and then it uses the github-releases command line tool to automatically upload the client and server builds to the GitHub releases page of my repo. And finally, it uses WinSCP's command-line interface to upload the changed files to my server using ftp.
Pseudocode:
//create the github release tag
github-release.exe release --user [username] --repo [reponame] --tag [version] --name "[version]" --security-token [github security-token] --pre-release
//build, zip, and upload the client to github.
:client
[EnginePath]\Engine\Build\BatchFiles\RunUAT.bat [Client arguments]
"C:\Program Files\WinRAR\Rar.exe" a -ep1 -r [zip path] [folder to zip path]
github-release.exe upload --user [username] --repo [reponame] --tag [version] --name [filename for github] --file [zip path] --security-token [Github security-token]
//Build, upload to remote (using ftp), zip, and upload server to github.
:server
call [EnginePath]\Engine\Build\BatchFiles\RunUAT.bat [Server arguments]
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script=uploadscript.txt
"C:\Program Files\WinRAR\Rar.exe" a -ep1 -r [server zip path] [server folder to zip path]
github-release.exe upload --user [username] --repo [reponame] --tag [version] --name [server filename for github] --file [server zip path] --security-token [Github security-token]
The code above shows the basic steps I'm taking to automate this. One big improvement I made is to break up the script into separate batch files which allows me to execute multiple steps in parallel. Although it is not possible to run two builds at once using the RunUAT script from unreal, it is possible to start building the server right as the client has finished, instead of, waiting for the client to upload to GitHub first. I achieved this by putting the upload commands in a separate batch script and calling that batch script from using the "start" command to start it as a separate session. I did the same with the server to allow it to upload using FTP and zip/upload to GitHub in parallel.
Below you can download the zip containing all the scripts I used, you might need to do some tweaking to set up the parameters to point to your GitHub account, your project folder, your build folder, etc. If you have found ways to improve this script, be sure to let me know in the comments so I can update the files.
Assets 1
AutomationScripts (zip)