name: Create releases
on:
  schedule:
    - cron: '0 5 * * *' # every day at 5am UTC
  push:
    branches:
      - main

jobs:
  release:
    name: release
    if: github.ref == 'refs/heads/main' && github.repository == 'anthropics/anthropic-sdk-python'
    runs-on: ubuntu-latest
    environment: production-release

    steps:
      - uses: actions/checkout@v6

      - uses: stainless-api/trigger-release-please@v1
        id: release
        with:
          repo: ${{ github.event.repository.full_name }}
          stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}

      - name: Install uv
        if: ${{ steps.release.outputs.releases_created }}
        uses: astral-sh/setup-uv@v5
        with:
          version: '0.9.13'

      - name: Publish to PyPI
        if: ${{ steps.release.outputs.releases_created }}
        run: |
          bash ./bin/publish-pypi
        env:
          PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN || secrets.PYPI_TOKEN }}
