name: Release Python Package

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

env:
  IMAGE_TAG: protoc-gen-validate:${{ github.sha }}
  REF_NAME: ${{ github.ref_name }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Build and export to Docker
        uses: docker/build-push-action@v6
        with:
          context: .
          load: true
          push: false
          tags: ${{ env.IMAGE_TAG }}
      - run: |
          docker run --rm \
          --env PYPI_REPO=pypi \
          --env PGV_PYPI_TOKEN="${{ secrets.PGV_PYPI_TOKEN }}" \
          ${{ env.IMAGE_TAG }} SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.REF_NAME }} python-release
