avatarOlivier Revial

Summary

This article discusses the use of Trunk-Based Development as a branching strategy for a Flutter app CI/CD pipeline using Github Actions.

Abstract

The article is part of a series on CI/CD for a Flutter app with Github Actions. It focuses on defining a branching strategy for the project, using Trunk-Based Development as the chosen method. The author explains the benefits of using a "one branch workflow" and short-lived feature branches, and describes the development and release processes for UAT and production environments. The article also provides a visual schema of the branching strategy and references for further reading.

Bullet points

  • The article is part of a series on CI/CD for a Flutter app with Github Actions.
  • The article focuses on defining a branching strategy for the project.
  • Trunk-Based Development is chosen as the branching strategy.
  • The benefits of using a "one branch workflow" and short-lived feature branches are explained.
  • The development and release processes for UAT and production environments are described.
  • A visual schema of the branching strategy is provided.
  • References for further reading are included.

CI/CD for a Flutter app with Github Actions: defining a branching strategy

Welcome to this CI/CD series! 👋

If you just got there, make sure you read what environments we chose as we will use them as the base of our branching strategy.

Photo by Michal Matlon on Unsplash

Any modern development project is control versioned, and when working with teammates on a project we need to pick a branching strategy because not every commit can be pushed to a single branch.

As an addition we want to be able to automate deployments to the stores for our different environments as defined in the previous article which means we need to find a way to identify what commits should be pushed to UAT and production environments.

Using Trunk-Based Development

We will use Trunk Based Development as our branching strategy, i.e. a “one branch workflow”. The reason for this choice is that we want to keep things as simple as possible and avoid endless rebases/merges. We think that a two-branches git workflow (e.g. Gitflow workflow) is overkill for our usecase.

If you’re new to trunk based development and don’t understand this choice you can read this great article from BAM.

In short we will have a main branch that will always be our “source of truth” and ready to be tested.

Development process

Our developments will be done on short-lived feature branches that will then be rebased onto main branch, as described in the following schema:

Trunk-based development

Notes:

  • bugfixes that fix UAT bugs should be pushed to main branch exactly the way we do it with feature branches.
  • your Git branching might differ if you have a more complex organization or way more developers then we do, but we personally try to keep it simple 🙂

Release process

With trunk-based development it will be easy to deploy commits to our UAT and production environments:

  • UAT - Every change added to the main branch will trigger a UAT release that will be sent to the UAT store → the release will be sent to the stores’ “internal tests” channel (of the UAT app) → a Github Actions workflow will be responsible for tagging the new UAT release version → exception: adding only documentation to the repo should not trigger new releases
  • PROD - A manual Github Actions workflow will trigger a PROD release that will be sent to the PROD store → this release will be sent to the stores’ “internal tests” channel (of the production app) → Github Actions workflow will be responsible for tagging the new PROD release version

To keep things simple:

  • commits on main branch = features ready to be tested in UAT
  • release/uat/x.y.z tags = UAT releases
  • release/prod/x.y.z tags = production releases

Here is a schema that sums-up above statements:

ℹ️ I forgot to add appropriate versions tags in the form release/env/x.y.z on this schema, and I can’t find the source file anymore, sorry!

Thank you for reading! In the next article we will start building, testing and analyzing our app 🧪📦👀

To see the complete topics of this series, please head to the series overview article.

🗃️ Source code: https://github.com/orevial/flutter-ci-cd-demo/

References

Flutter
Github Actions
Ci Cd Pipeline
Branching Strategy
Git
Recommended from ReadMedium