Self hosted github runners on Mac Mini (M2/8G/256G)
Recently I successfully published my first iOS App to App Store. I used Github Actions to automate the build and deployment process. I was using the free Github Actions minutes, but I found it is not enough for my needs. I managed to use those free credits comes wit my subscription to debug the pipelines and finally published the first version of my app.
Github teams subscritpion comes with 3000 free minutes per month, and the ratio for macOS runner is 10:1, which means I can use 300 minutes per month for macOS runner. it takes about 15 minutes to build and deploy my app on Github-hosted runners, so I can only run the pipeline 20 times per month. Additional macOS minutes are charged at $0.08 per minute, leading to a cost of $1.2 per build and deploy.
However, I can easily get a basic model of Mac Mini M2 with 8GB RAM and 256GB SSD for $400 in the market. This model is always on sale, and my assumption is that the 256GB model provides only half-speed SSD, and consumers are better off buying the 512GB model. But for my use case, I only need to run the pipeline, and the storage is not a concern. With this one-time investment, I can run the pipeline as many times as I want.
After some digging, I found out that Tart, a virtualization toolset to build, run and manage macOS and Linux virtual machines on Apple Silicon, is a good choice for me. I can run the self-hosted runner inside the virtual machine and the pipelines will not jerpordize the host system. As you know, the iOS build and deployment process can mess up with the keychains, provisioning profiles, and certificates, so it is better to run the pipeline in a clean environment.
tart provides a macOS image that is pre-configured with xcode and other tools, even the github runner is pre-installed. basically I can just clone a image and start the vm, then register the runner with my github repo.
Here are some scripts for your reference.
1 | # install tart |
Then you are good to go. You should see the runner is online in your github repo. You can now run the pipeline on your self-hosted runner.