Search code examples
androidgithubgithub-actionscicd

Extract version from Github PR title


I'm building Android CD Pipeline on Github action to automate app deployment to play store. Currently I'm able to update the versionCode using android-version-action action.

But on Google Play console version name is "1" only as not finding way to update this.

So I come up with solution when I raise PR from development to master branch my PR title will be as Android App Release V1.0.0

I'm looking for help to extract this 1.0.0 from PR title. So I can update the versionName & release artifact directly through github actions without any human interaction.

Currently this is my cd pipeline :

name: Android CD Pipeline

on:
  push:
    branches:
      - master

jobs:
  build:
    name: Deploy Android App
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set Up JDK 18
        uses: actions/setup-java@v3
        with:
          java-version: '18'
          distribution: 'temurin'

      - name: Bump version code
        uses: chkfung/[email protected]
        with:
          gradlePath: app/build.gradle.kts
          versionCode: ${{github.run_number}}

Edit : using this ${{ github.event.pull_request.title }} command I can fetch title. but how can I get versionName from it which will be like 1.0.0.


Solution

  • If you read this topic, you can see that GitHub actions is not very open to manipulate strings (at least for now). I can suggest some of alternative solutions:

    • Just simply put the PR title as V1.0.0, unless you have a multiple platforms project, what other than Android release you are going to release?
    • Or, you can just put a git TAG for a new release, then fetch and manipulate the release version via Gradle (or kotlin kts)