Architecture
                        Write quality mobile apps in any architecture
                            
                         
    
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: - masterThe '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.
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
}
  APP_VERSION = "1.0.1"
}
android {
  buildToolsVersion APP_VERSION
  defaultConfig {
    versionName APP_VERSION
  }
}
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
Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.