Skip to content
terminal

GitHub Action

Setup Google App Version CLI Tool

latest Latest version

Setup Google App Version CLI Tool

terminal

Setup Google App Version CLI Tool

Setup the Google App Version CLI in a workflow job

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Setup Google App Version CLI Tool

uses: inspire-labs-tms-tech/google-play-app-version-code-cli@latest

Learn more about this action in inspire-labs-tms-tech/google-play-app-version-code-cli

Choose a version

[CLI Utility] Google Play App Version Code

Retrieve the latest (or next) versionCode for a Google Play App. Useful for automating build scripts.

GitHub Action

Using the CLI is incredibly simple, using the pre-compiled GitHub Action:

jobs:
  job:
    # ...
    steps:
      - name: Setup Google App Version CLI Tool
        uses: inspire-labs-tms-tech/google-play-app-version-code-cli@latest
        with:
          version: latest # CLI version to use (defaults to `latest`
  
      - name: get next version code
        id: version_code
        run: NEXT="$(google-app-version -p com.inspiretmstech.mobile -f "$JSON" next)" && echo "version_code=$NEXT" >> $GITHUB_OUTPUT
        env:
          JSON: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }} # rename with your secret, where the secret-value is the copy-pasted output of your service account's credentials.json file

      - name: use next versionCode
        run: echo "next version code - ${{ steps.version_code.outputs.version_code }}"

Setup

Service Account

The CLI uses a Google Service Account JSON file to authenticate.

Setup your service account according to the Expo documentation: https://github.com/expo/fyi/blob/main/creating-google-service-account.md

Ensure to download a JSON version of the key-file.

Install the CLI

Latest Version

# Download the Latest Release
curl -LO https://github.com/inspire-labs-tms-tech/google-play-app-version-code-cli/releases/latest/download/google-app-version.deb

# Install the Latest Release
sudo apt-get install ./google-app-version.deb

# (Optional) Add the Latest Release to Path (to simply call `google-app-version` from any working directory)
sudo ln -s /usr/local/bin/google-app-version/bin/google-app-version /usr/bin

Specific Version

# Download a Specific Release
# Replace `v20240613.234416` in the URL with the desired/pinned version
curl -LO https://github.com/inspire-labs-tms-tech/google-play-app-version-code-cli/releases/download/v20240613.234416/google-app-version.deb

# Install the Release
sudo apt-get install ./google-app-version.deb

# (Optional) Add the Release to Path (to simply call `google-app-version` from any working directory)
sudo ln -s /usr/local/bin/google-app-version/bin/google-app-version /usr/bin

Usage

  • The CLI supports two output modes:

    1. the latest/current versionCode of an application
    2. the next versionCode of an application (just latest + 1)
  • The contents of the service account's key.json file should be passed as an environment variable (useful for CI/CD environments)

Example

For an application with a production build versionCode of 14:

Latest

JSON=$(cat ~/key.json) && google-app-version latest -f "$JSON" -p com.company.app
# 14

Next

JSON=$(cat ~/path/to/key.json) && google-app-version next -f "$JSON" -p com.company.app
# 15

Parameters

  • Version (Position 0): google-app-version <VERSION>
    • latest: the latest, currently released versionCode of an application
      • google-app-version latest ...
    • next: the next-available versionCode of an application
      • google-app-version next ...

Required Arguments

  • JSON File Contents (-f / --file): the contents (not filepath) of a JSON file for the google service account's credentials
    • Note: if the file's contents are stored locally, instead of in an environment variable, you can use the following command structure to load the JSON file's contents into an environment variable:
      • MY_JSON_FILE_CONTENTS=$(cat ~/path/to/key.json) && google-app-version -f "$MY_JSON_FILE_CONTENTS" ...
  • Package Name (-p / --package): the package (not application) name
    • this is set the after your first release
    • in the below example image, (Google Play Console > Home > Apps) the package name is com.inspiretmstech.mobile

Optional Arguments

  • Verbose Output (-v / --verbose): print debug-level information to the console
  • Help (-h / --help): print full documentation and exit
  • Version (-V / --version): print the CLI version and exit