ThoughtWorks
  • Contato
  • Español
  • Deutsch
  • English
  • 中文
Visão geral
  • Cultura de engenharia, mentalidade de entrega

    Adote uma abordagem moderna ao desenvolvimento de software e entregue valor mais rapidamente

    Inteligência para tomada de decisões

    Explore seus dados para descobrir novas fontes de valor

  • Modelo de operação sem atritos

    Evolua a capacidade da sua organização de responder a mudanças

    Estratégia de plataforma

    Crie plataformas de tecnologia que se adaptam à sua estratégia de negócios

  • Design de experiência e inovação de produtos

    Planeje, execute e evolua rapidamente produtos e experiências excepcionais

    Parcerias

    Extraindo valor da nossa rede de parceiras para potencializar os resultados que entregamos a nossas clientes

Visão geral
  • Setor automotivo
  • Cleantech, energia e utilidade pública
  • Serviços financeiros e seguros
  • Saúde
  • Mídia
  • Organizações sem fins lucrativos
  • Setor público
  • Varejo e e-commerce
  • Viagem e transporte
Visão geral

Destaques

  • Tecnologia

    Uma análise abrangente de tecnologias e práticas de engenharia nas empresas

  • Negócios

    Mantenha-se em dia com as mais recentes tendências da indústria

  • Cultura

    Um espaço para conteúdo sobre desenvolvimento profissional e nossa visão sobre justiça social e inclusão

Ferramentas e Publicações Digitais

  • Technology Radar

    Um guia com opiniões firmes sobre as fronteiras da tecnologia

  • Perspectives

    Uma publicação para líderes digitais

  • Modelo de Fluência Digital

    Um modelo para priorizar as competências digitais necessárias para se navegar a incerteza

  • Decoder

    Um guia de A a Z sobre tecnologia para lideranças executivas

Todos os Insights

  • Artigos

    Visões de especialistas para ajudar seu negócio a crescer

  • Blogs

    Pontos de vista pessoais de ThoughtWorkers de todo o mundo

  • Livros

    Explore nossa vasta biblioteca

  • Podcasts

    Discussões instigantes sobre as últimas novidades em negócios e tecnologia

Visão geral
  • Processo de aplicação

    O que esperar de uma entrevista conosco

  • Pessoas em início ou mudança de carreira

    Comece sua jornada na tecnologia aqui

  • Vagas abertas

    Encontre oportunidades na sua região

  • Conecte-se

    Assine nossa newsletter mensal

Visão geral
  • Conferências e eventos
  • Diversidade e Inclusão
  • Notícias
  • Código aberto
  • Nossas lideranças
  • Transformação social
  • Español
  • Deutsch
  • English
  • 中文
ThoughtWorksMenu
  • Fechar   ✕
  • O que fazemos
  • Com quem trabalhamos
  • Insights
  • Carreiras
  • Sobre
  • Contato
  • Voltar
  • Fechar   ✕
  • Visão geral
  • Cultura de engenharia, mentalidade de entrega

    Adote uma abordagem moderna ao desenvolvimento de software e entregue valor mais rapidamente

  • Design de experiência e inovação de produtos

    Planeje, execute e evolua rapidamente produtos e experiências excepcionais

  • Modelo de operação sem atritos

    Evolua a capacidade da sua organização de responder a mudanças

  • Inteligência para tomada de decisões

    Explore seus dados para descobrir novas fontes de valor

  • Parcerias

    Extraindo valor da nossa rede de parceiras para potencializar os resultados que entregamos a nossas clientes

  • Estratégia de plataforma

    Crie plataformas de tecnologia que se adaptam à sua estratégia de negócios

  • Voltar
  • Fechar   ✕
  • Visão geral
  • Setor automotivo
  • Cleantech, energia e utilidade pública
  • Serviços financeiros e seguros
  • Saúde
  • Mídia
  • Organizações sem fins lucrativos
  • Setor público
  • Varejo e e-commerce
  • Viagem e transporte
  • Voltar
  • Fechar   ✕
  • Visão geral
  • Destaques

  • Tecnologia

    Uma análise abrangente de tecnologias e práticas de engenharia nas empresas

  • Negócios

    Mantenha-se em dia com as mais recentes tendências da indústria

  • Cultura

    Um espaço para conteúdo sobre desenvolvimento profissional e nossa visão sobre justiça social e inclusão

  • Ferramentas e Publicações Digitais

  • Technology Radar

    Um guia com opiniões firmes sobre as fronteiras da tecnologia

  • Perspectives

    Uma publicação para líderes digitais

  • Modelo de Fluência Digital

    Um modelo para priorizar as competências digitais necessárias para se navegar a incerteza

  • Decoder

    Um guia de A a Z sobre tecnologia para lideranças executivas

  • Todos os Insights

  • Artigos

    Visões de especialistas para ajudar seu negócio a crescer

  • Blogs

    Pontos de vista pessoais de ThoughtWorkers de todo o mundo

  • Livros

    Explore nossa vasta biblioteca

  • Podcasts

    Discussões instigantes sobre as últimas novidades em negócios e tecnologia

  • Voltar
  • Fechar   ✕
  • Visão geral
  • Processo de aplicação

    O que esperar de uma entrevista conosco

  • Pessoas em início ou mudança de carreira

    Comece sua jornada na tecnologia aqui

  • Vagas abertas

    Encontre oportunidades na sua região

  • Conecte-se

    Assine nossa newsletter mensal

  • Voltar
  • Fechar   ✕
  • Visão geral
  • Conferências e eventos
  • Diversidade e Inclusão
  • Notícias
  • Código aberto
  • Nossas lideranças
  • Transformação social
Blogs
Selecione um tema
Ver todos os tópicosFechar
Tecnologia 
Gestão de Projetos Agil Nuvem Entrega Contínua Ciência e Engenharia de Dados Defendendo a Internet Livre Arquitetura Evolutiva Design de Experiência IoT Linguagens, Ferramentas & Frameworks Modernização de sistemas legados Machine Learning & Artificial Intelligence Microsserviços Plataformas Segurança Testes de Software Estratégia de Tecnologia 
O negócio 
Serviços Financeiros Saúde Global Inovação Varejo Transformação 
Carreiras 
Dicas de Carreira Diversidade e Inclusão Transformação social 
Blogs

Topics

Escolha um tópico
  • Tecnologia
    Tecnologia
  • Tecnologia Visão Geral
  • Gestão de Projetos Agil
  • Nuvem
  • Entrega Contínua
  • Ciência e Engenharia de Dados
  • Defendendo a Internet Livre
  • Arquitetura Evolutiva
  • Design de Experiência
  • IoT
  • Linguagens, Ferramentas & Frameworks
  • Modernização de sistemas legados
  • Machine Learning & Artificial Intelligence
  • Microsserviços
  • Plataformas
  • Segurança
  • Testes de Software
  • Estratégia de Tecnologia
  • O negócio
    O negócio
  • O negócio Visão Geral
  • Serviços Financeiros
  • Saúde Global
  • Inovação
  • Varejo
  • Transformação
  • Carreiras
    Carreiras
  • Carreiras Visão Geral
  • Dicas de Carreira
  • Diversidade e Inclusão
  • Transformação social
Entrega ContínuaTecnologia

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
Posts relacionados
Design de Experiência

Escrevendo aplicativos móveis de qualidade em qualquer arquitetura

Leandro Alonso
Saiba mais
Pune

Building Better Behavior Tests for Mobile Apps

Priyank Gupta
Saiba mais
Design de Experiência

Designing for Mobile

Jonny Schneider
Saiba mais
  • O que fazemos
  • Com quem trabalhamos
  • Insights
  • Carreiras
  • Sobre
  • Contato

WeChat

×
QR code to ThoughtWorks China WeChat subscription account

Mídia e relações públicas | Política de privacidade | Modern Slavery statement ThoughtWorks| Acessibilidade | © 2021 ThoughtWorks, Inc.