# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Test repository dispatch

on:
  push:
#branches: [ "main" ]
    # Publish semver tags as releases.
    tags: [ 'v*.*.*' ]
    
permissions:
  contents: read

jobs:
  release-build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Check tag name
        run: |
          TAG=${{ github.ref_name }}
          echo "Tag name: $TAG"
          REF=${{ github.ref }}
          echo "Tag name: $REF"

      - name: Trigger next workflow
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_GHA_PAT }}
          repository: ${{ github.repository }}
          event-type: trigger-pypi-package
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "tag": "${{ github.ref_name }}" }'
