Mobile Application

Use Case: Mobile Application Versioning with Versioning Tools API

Context

In mobile application development, managing versions correctly is crucial for tracking changes, distributing updates, and maintaining consistency. This use case describes how a developer can use the Versioning Tools API to automate versioning locally. This process will help ensure that each release is correctly versioned and tagged, streamlining the development and release cycle.

Scenario

A developer is working on a mobile application and has completed a new feature. To prepare for the release, the developer needs to:

  1. Retrieve the next semantic version from the Versioning Tools API.

  2. Update the application’s version in the local codebase.

  3. Tag the version in the version control system (Git).

  4. Prepare the application for deployment.

Step-by-Step Guide

1. Retrieve the Next Version Identifier

The developer needs to get the next semantic version for the mobile application. This step involves calling the Versioning Tools API.

Command:

curl -X 'POST' \
  'https://api.versioning.tools/v1/SemVer/myMobileApp?apiKey=YOUR_API_KEY' \
  -H 'accept: */*'

Explanation:

  • myMobileApp: Replace with your service ID, representing the mobile application.

  • YOUR_API_KEY: Replace with your API key.

Response:

{
  "version": "2.1.0"
}

The response provides the next version number, for example, 2.1.0.

2. Update the Application’s Version

Next, update the mobile application’s version in the local codebase. The method to update the version will depend on the mobile platform (e.g., Android, iOS).

For Android:

  1. Update build.gradle:

    • Open app/build.gradle.

    • Modify the versionCode and versionName:

      android {
          ...
          defaultConfig {
              ...
              versionCode 21
              versionName "2.1.0"
          }
      }

    Explanation:

    • versionCode: An integer representing the version number for the APK. Increment this for each new release.

    • versionName: The human-readable version string.

For iOS:

  1. Update Info.plist:

    • Open Info.plist.

    • Update the CFBundleShortVersionString and CFBundleVersion:

      <key>CFBundleShortVersionString</key>
      <string>2.1.0</string>
      <key>CFBundleVersion</key>
      <string>21</string>

    Explanation:

    • CFBundleShortVersionString: The version number shown to users.

    • CFBundleVersion: The build number for internal tracking.

3. Tag the Version in Git

Once the local codebase is updated, tag the new version in the Git repository.

Command:

git tag v2.1.0 -m "Release version 2.1.0"

Explanation:

  • v2.1.0: The version received from the API.

  • -m "Release version 2.1.0": A message describing the tag.

4. Push the Tag to the Remote Repository

After tagging the version locally, push the tag to the remote repository.

Command:

git push origin v2.1.0

Explanation:

  • origin: The name of the remote repository.

  • v2.1.0: The tag being pushed.

5. Prepare for Deployment

Prepare the application for deployment to the respective app stores (Google Play Store, Apple App Store). Ensure that:

  • Build Artifacts: Build the application with the updated version.

  • Release Notes: Update release notes or changelogs with information about the new version.

  • App Store Configuration: Ensure the version number and build metadata match what you have set locally.

Example Workflow

Here is an example workflow a developer might follow:

  1. Complete Feature Development:

    • Implement new features and ensure all tests pass.

  2. Retrieve the Next Version:

    NEXT_VERSION=$(curl -X 'POST' \
      'https://api.versioning.tools/v1/SemVer/myMobileApp?apiKey=YOUR_API_KEY' \
      -H 'accept: */*')
  3. Update the Application’s Version:

    • For Android or iOS, update the respective configuration files with NEXT_VERSION.

  4. Tag the Repository:

    git tag "v$NEXT_VERSION" -m "Release version $NEXT_VERSION"
  5. Push the Tag:

    git push origin "v$NEXT_VERSION"
  6. Prepare for Deployment:

    • Build the application and update relevant deployment documentation.


Last updated