name: Release to PyPI

on:
  push:
    branches:
      - main # or whatever branch you want to use
      - pypi-release

jobs:
  release:
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/open-webui
    permissions:
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - name: Install Git
        run: sudo apt-get update && sudo apt-get install -y git
      - uses: actions/setup-node@v5
        with:
          node-version: 22
      - uses: actions/setup-python@v6
        with:
          python-version: 3.11
      - name: Build
        run: |
          python -m pip install --upgrade pip
          pip install build
          python -m build .
      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
