name: Retag Commit

on:
  push:
    branches:
      - main

jobs:
  retag:
    runs-on: ubuntu-latest
    env:
      TAG_NAME: wasp-v0.13-template
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4

      - name: Configure Git
        run: |
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git config user.name "github-actions[bot]"

      - name: Delete Old Tag
        run: |
          git tag -d ${{ env.TAG_NAME }} || true 
          git push origin :refs/tags/${{ env.TAG_NAME }} || true

      - name: Add New Tag
        run: |
          git tag ${{ env.TAG_NAME }}
          git push origin ${{ env.TAG_NAME }}
