name: version-code-change

on:
  push:
    tags:
      - '*'

jobs:
  update-version-code:
    name: Update version.properties
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          token: "${{ secrets.GITHUB_TOKEN }}"
          ref: master
          fetch-depth: 0
      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: 17
          distribution: 'temurin'
      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v4
      - name: Update version file
        run: ./gradlew :updateVersionPropertiesFile --no-daemon
      - name: Log version.properties file
        run: cat app/version.properties
      - name: Commit version.properties changes
        run: |
          git config --local user.name "github-actions"
          git config --local user.email "github-actions@github.com"
          git status
          git add .
          git commit -am "github-actions[bot]: Updated version.properties"
      - name: Push version.properties changes
        run: git push