USE DEVOPS TO AUTOMATE YOUR WORKFLOWS

Using GitHub Actions with iOS and Android Xamarin apps

Get started by creating Automated Builds on each Push or Merge Request

DevOps are a must-have in every Software Architect’s belt, and GitHub’s Actions for CI/CD is just another step to make DevOps accessible for everyone. Ever since I got a chance to see the immense impact that CI/CD can have on efficiency of mobile teams, I knew it is a no-brainer for every team project!

Introduction

This document will teach you the easiest use of GitHub Actions: Running a GitHub Action to perform a sanity test on your apps— make sure the iOS & Android apps build on each commit or merge request, ensuring that there is no bug introduced in that commit which breaks the build.

Merge Request with a missing semicolon in MainActivity fails Android Check

What You Need

You need any Xamarin solution in a repository on Github. Yes, it can be Xamarin.Native or Xamarin.Forms, and the repository can be public or private. You don’t need Jenkins, Azure DevOps, CircleCI, Bit-rise or anything else that sounds fancy because GitHub Actions has everything you need.

How easy is this?

It shouldn’t take you longer than 60 seconds:

Go to your repository’s main folder and tap the Create new file button Name the file .github/workflows/main.yml and add this code snippet Replace Blank with the names you are using, and tap Commit new file

Contents of the main.yml file

Your Action should immediately start once you commit the file.

You can only see the Actions tab if you own that repository, but you can see the Checks tab in a Pull requests if the repo is Public.

What’s happening here?

The Action/Workflow named “CI on Push and Pull Request” runs on every push and merge request, and consists of 3 jobs. The Practice job is not required, it contains multiple steps and it’s output logs will help understand and create awesome workflows yourself.

Output Logs for the “Practice” job

The other two jobs first cd (change directory) into the folder that has the solution, and then restores all the nuget packages. And then it performs a rebuild all which passes only if all the dependent projects build. So, if the shared project (Core/Forms) is broken, both iOS & Android checks will fail.

Log from failed job conveniently points out the fix

To test it, I successfully created multiple merge requests to add the automated workflow, including this one.

Special Thanks

I tried and researched for months to get GitHub Actions to work with Xamarin, until I gave up, telling myself the grapes are sour, that I was just too ambitious. But alas I figured it out! Through this journey I reached out to and took inspiration from:

Please let me know what you think and what you build in the comments or @saamerm. Also please add some love to this Xamarin Forms enhancement request with some likes.