Here's my "local build pipeline" for Unity. It consists of a C# Editor script defining the various build targets and a convenient BuildAll
method, and a shell script that invokes the latter method.
Warning Do not copy it verbatim and expect it to work. You will need to adapt it to your project, since it's making assumptions about export platforms, paths, and included scenes. Consider it a starting point for your own script!
Running headless builds like this is a lot less work than switching platforms and triggering builds manually in the editor, and it is most definitely faster than using the god-awfully slow Unity Cloud Build to do it. (In my game, running this local pipeline produces builds for all my targeted platforms in just over 7 minutes on my Macbook Pro, while Unity Cloud Build would often take longer than an hour.)
As you can see from the code, it will read the secrets required for Play Store publishing from the environment. Ideally, in the future it will also source the Android build number like this (or maybe even increment it automatically.)
I'm a perpetual Unity newbie, so if you have any suggestions on how to tweak this further, let me know in the comments!
– @hmans, July 2020 (updated March 2023)
crazy nice, thanks for sharing. will try to get this running in windows