name: release_tag_branch
author: Bolt lee
inputs:
  VERSION:
    required: true
    default: ''
runs:
  using: "composite"
  steps:
    - name: release_tag_branch
      shell: bash
      run: |
        set -xoe
        echo "Tagging major ${{ inputs.VERSION }}"
        git config --global user.email "team.devops@groundx.xyz"
        git config --global user.name "circleci-gx"

        git tag -a ${{ inputs.VERSION }} -m "${{ github.job }}"
        git push origin ${{ inputs.VERSION }}

        if [[ "release/v" = $(git log --oneline -1 | grep -o "release/v") ]]; then
          echo "Delete branch release/${{ inputs.VERSION }}"
          git push origin --delete release/${{ inputs.VERSION }}
        else
          echo "Need to delete branch manually"
        fi