---
name: Release

# yamllint disable-line rule:truthy
on:
  release:
    types:
      - published

jobs:
  release:
    name: Releasing to PyPi
    runs-on: ubuntu-latest
    environment:
      name: release
      url: https://pypi.org/project/go2rtc-client/
    permissions:
      contents: write
      id-token: write
    steps:
      - name: ⤵️ Check out code from GitHub
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - name: 🏗 Set up uv
        uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
        with:
          enable-cache: true
      - name: 🏗 Set package version
        run: |
          sed -i "s/^version = \".*\"/version = \"${{ github.event.release.tag_name }}\"/" pyproject.toml
      - name: 🏗 Build package
        run: uv build
      - name: 🚀 Publish to PyPi
        run: uv publish
      - name: ✍️ Sign published artifacts
        uses: sigstore/gh-action-sigstore-python@a5caf349bc536fbef3668a10ed7f5cd309a4b53d # v3.2.0
        with:
          inputs: ./dist/*.tar.gz ./dist/*.whl
          release-signing-artifacts: true
