Master
ThoughtWorks
Menú
Cerrar
  • Nuestros Servicios
    • Visión general
    • Experiencia del Cliente, Producto y Diseño
    • Estrategia, Ingeniería y Análisis de Datos
    • Transformación Digital y Operaciones
    • Modernización Empresarial, Plataformas y la Nube
  • ¿Con quién trabajamos?
    • Visión general
    • Sector Automotriz
    • Servicios Médicos
    • Sector Público
    • Cleantech y Servicios Públicos
    • Medios y Publicidad
    • E-commerce y Retail
    • Servicios Financieros y Aseguradoras
    • Organizaciones sin fines de lucro
    • Viajes y Transporte
  • Insights
    • Visión general
    • Destacados

      • Tecnología

        Una exploración profunda de tecnología empresarial y excelencia en ingeniería

      • Negocios

        Mantenerse actualizado con los últimos insights empresariales y de industria para líderes digitales

      • Cultura

        El espacio para encontrar contenido y tips de desarrollo profesional, y nuestra visión sobre la justicia social y la inclusión

    • Publicaciones Digitales y Herramientas

      • Radar Tecnológico

        Nuestra guía de tendencias tecnológicas actuales

      • Opiniones

        Una publicación para líderes digitales

      • Digital Fluency Model

        Un modelo para priorizar las capacidad digitales necesarias para navegar en la incertidumbre

      • Decoder

        Una guía tecnológica de la A a la Z para líderes de negocio

    • Todos los Insights

      • Artículos

        Opiniones profesionales que ayudarán al crecimiento de tu negocio

      • Blogs

        Opiniones personales de ThoughtWorkers de todo del mundo

      • Libros

        Navega a través de nuestra extensa biblioteca

      • Podcasts

        Emocionantes charlas sobre las últimas tendencias en negocios y tecnología

  • Carreras
    • Visión general
    • Proceso de Aplicación

      Descubre lo que te espera durante nuestro proceso de selección

    • Graduados y cambio de carreras

      Empieza tu carrera en tecnología con el pie derecho

    • Ofertas de trabajo

      Encuentra puestos vacantes en tu región

    • Mantente conectado

      Suscríbete a nuestro boletín mensual

  • Acerca de Nosotros
    • Visión general
    • Nuestro Propósito
    • Premios y Reconocimientos
    • Diversidad, equidad e inclusión
    • Nuestros líderes
    • Asociaciones
    • Noticias
    • Conferencias y eventos
  • Contacto
Spain | Español
  • United States United States
    English
  • China China
    中文 | English
  • India India
    English
  • Canada Canada
    English
  • Singapore Singapore
    English
  • United Kingdom United Kingdom
    English
  • Australia Australia
    English
  • Germany Germany
    English | Deutsch
  • Brazil Brazil
    English | Português
  • Spain Spain
    English | Español
  • Global Global
    English
Blogs
Selecciona un tema
Ver todos los temasCerrar
Tecnología 
Gestión de Proyectos Agiles La Nube Entrega Continua Ciencia e Ingenieria de Datos Defendiendo el Internet Libre Arquitectura Evolutiva Experiencia de Usuario IoT  Lenguajes, Herramientas y Frameworks Modernización de sistemas heredados Machine Learning & Artificial Intelligence Microservicios Plataformas Seguridad Pruebas de Software Estrategia Digital 
Negocio 
Servicios Financieros Salud Global Innovación Ventas  Transformación 
Carreras 
Hacks Para Tu Carrera Diversidad e Inclusión Cambio Social 
Blogs

Temas

Elegir tema
  • Tecnología
    Tecnología
  • Tecnología Visión General
  • Gestión de Proyectos Agiles
  • La Nube
  • Entrega Continua
  • Ciencia e Ingenieria de Datos
  • Defendiendo el Internet Libre
  • Arquitectura Evolutiva
  • Experiencia de Usuario
  • IoT
  • Lenguajes, Herramientas y Frameworks
  • Modernización de sistemas heredados
  • Machine Learning & Artificial Intelligence
  • Microservicios
  • Plataformas
  • Seguridad
  • Pruebas de Software
  • Estrategia Digital
  • Negocio
    Negocio
  • Negocio Visión General
  • Servicios Financieros
  • Salud Global
  • Innovación
  • Ventas
  • Transformación
  • Carreras
    Carreras
  • Carreras Visión General
  • Hacks Para Tu Carrera
  • Diversidad e Inclusión
  • Cambio Social
Entrega ContinuaTecnología

Automating semantic versioning model in mobile releases

Guilherme Cherubini Guilherme Cherubini
Vanessa Medeiros Vanessa Medeiros

Published: Feb 4, 2020

Mobile applications have become increasingly important in business, transforming both the business and software development practices. 

In this new dynamic and agile reality it’s vital that development teams obtain constant customer feedback so that they can operate effectively. The practice of continuous delivery can help because software releases are made frequently and with minor changes — this helps derisk deployment. With this approach, the software is tested constantly and issues can be detected and fixed quickly.

One example of this type of automation was in a critical project that we worked on for a client. It was a mobile framework that was used by a large application to allow the end user to make in-app purchases. That had a very fragile architecture, with no defined code standards, with non-effective unit tests (since they do not guarantee the main business logic of the application) and without any automated processes.

In this post we will demonstrate how we automated the distribution process using semantic versioning (SemVer) model. The initiative bought the team more time to invest in other improvements actions, such as: architecture evolution, bug fixes and unit testing.

Starting out with SemVer

The SemVer specification is a versioning model for software development projects, authored by Tom Preston, co-founder of GitHub. Using its set of rules makes it possible to distribute a project code in different stages and the relevant dev teams can choose the version that best suits them (this is what most of the libraries and frameworks do). Breaking changes, bug fixes or new features can be easily identified just by looking at the increased version number.

"Under this scheme, version numbers and the way they change convey meaning about the underlying code and what has been modified from one version to the next." 

In order to standardize the customer project infrastructure, we chose the GitLab CI system as a continuous integration and delivery platform, because it made it possible to automate the application distribution to  framework consumers, also known as: developers.

The GitLab CI pipeline was configured to have four stages: build, lint, test and release. Once the first three stages are successfully executed, the fourth stage, 'release', is made available to be launched. The following image displays the project pipeline screen:

Figure 1: Part of the GitLab CI interface, displaying the pipeline and the release jobs that can be executed manually

In a perfect world, we would have only one job that would receive the release type as a parameter that we’d like to perform. Unfortunately, the GitLab CI tool doesn’t allow parameters to be passed when executing a specific job. That said, at the time of writing, there’s an open ticket to add this feature at some point. 

For this reason we had to configure three different types of jobs (a flow of tasks to be executed), one for each type of distribution. Following the specification of SemVer: 

releaseAndBumpMajor: increments the 'major' value of the version (x.0.0) and reset the 'minor' and 'patch';
releaseAndBumpMinor: increments the 'minor' value of the version (5.x.0) and clears the 'patch';
releaseAndBumpPatch: increments the version 's patch value (5.0.x);

In order to define the three distribution jobs through GitLab CI, it was needed to configure the ".gitlab-ci.yml" file, which is responsible for defining the pipeline settings.
 
releaseAndBumpPatch:
 when: manual
 stage: release
 script:
   - fastlane release semverBumpType:patch
 only:
   - master
 
releaseAndBumpMinor:
 when: manual
 stage: release
 script:
   - fastlane release semverBumpType:minor
 only:
   - master
eleaseAndBumpMajor:
 when: manual
 stage: release
 script:
   - fastlane release semverBumpType:major only:
   - master
 
The 'when: manual' configuration allows us to launch the job with just one click through the GitLab CI interface (image 01). The 'only: master' setting defines that the job will be available when a commit is coming from the master branch, and the 'script: fastlane release ...' setting is responsible for incrementing and distributing the new version to the consumers.

We chose to use Fastlane in our project to make test automation and deploy easier. It also has an action called increment_version_number, which can pass the key 'bump_type' with the values of 'major', 'minor' or 'patch'. This action is already based on the SemVer model and makes it very simple to increment the version of your project. But, it’s also possible to use any other type of technique or even write a custom script that does this same type of work.

The Fastlane versioning action is only available for the iOS platform. However, this operation can be implemented with a shell script or even a Gradle task for Android applications. As you can see in the Gradle script below:
 
import java.util.regex.Pattern

task bumpSemver << {
  if (type != "major" && type != "minor" && type != "patch") {
    println "SemVer type param should be passed. (major, minor or patch)"
    return
  }

  def propsFile = file("sdk/build.gradle")
  def propsText = propsFile.getText()
  def patternVersionNumber = Pattern.compile(versionPropertyKey + "(\\s?)=(\\s?)\"(\\d+)\\.(\\d+)\\.(\\d+)\"")
  def matcherVersionNumber = patternVersionNumber.matcher(propsText)
  matcherVersionNumber.find()

  def major = Integer.parseInt(matcherVersionNumber.group(3))
  def minor = Integer.parseInt(matcherVersionNumber.group(4))
  def patch = Integer.parseInt(matcherVersionNumber.group(5))

  println "VERSION=" + major + "." + minor + "." + patch

  switch (type) {
    case "major":
      major++
      minor = 0
      patch = 0
      break
    case "minor":
      minor++
      patch = 0
      break
    case "patch":
      patch++
      break
    default:
      println "SemVer type should be passed: major, minor or patch"
      break
  }

  propsText = matcherVersionNumber.replaceAll(versionPropertyKey + " = \"" + major + "." + minor + "." + patch + "\"")
  propsFile.write(propsText)

  println "BUMPED VERSION=" + major + "." + minor + "." + patch
}

You must also change the build settings file by adding the current APP_VERSION extra property of the application:
 
  APP_VERSION = "1.0.1"
}

android {
  buildToolsVersion APP_VERSION

  defaultConfig {
    versionName APP_VERSION
  }
}

When executed the script gets the current version of the project through the APP_VERSION property and increment it according to the selected SemVer specification.

Part of the Fastfile file is presented below where the release lane (distribution action) is defined, which is executed by the previous defined jobs in the file ".gitlab-ci.yml" (Image 01). It receives the type of version (major / minor / patch) that we want to increment and distribute.
 
lane :release do |options|
   
# Increments the version according the passed type (major, minor or patch)

# iOS release
increment_version_number(bump_type: options[:semverBumpType])

# Android release
sh "../gradlew bumpSemver -Ptype=#{options[:senverBumpType]} -PversionPropertyKey=APP_VERSION"

# Gets the version number for possible automations
version = get_version_number(xcodeproj: "SDK.xcodeproj")

# Other automated operations

end

Also, you can align with your team other actions that need to be automated in your release process and add them to the location pointed out by the comment: "Other automated operations." Some interesting examples are: updating the changelog file, creating a Git tag for the commit, updating the project .podspec file, updating the remote repository with these new changes, etc. 

But don't forget to automate the most important operation, that’s the one responsible for distributing your software to Google Play or App Store.

Through this article, we have shown how it is possible to generate three different types of automated and versioned distributions. We hope this tip may have been useful for you and would allow for a more frequent distribution of software, with the benefits of versioning the SemVer model covers.

Technology Radar

Don't miss our opinionated guide to technology frontiers.

Subscribe
Blogs relacionados
Lenguajes, Herramientas y Frameworks

Write quality mobile apps in any architecture

Leandro Alonso
Aprende más
Pune

Building Better Behavior Tests for Mobile Apps

Priyank Gupta
Aprende más
Experiencia de Usuario

Designing for Mobile

Jonny Schneider
Aprende más
Master
Política de Privacidad | Declaración sobre la esclavitud moderna | Accesibilidad
Connect with us
×

WeChat

QR code to ThoughtWorks China WeChat subscription account
© 2021 ThoughtWorks, Inc.