From 23d562b1a24f7808c9b386d02880f5b77459848c Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Fri, 25 Jul 2025 09:26:47 -0700 Subject: [PATCH] build(github/manual_pypi_publish.yml): manual workflow to publish pip package - used for pushing dev releases (#12985) * build(github/manual_pypi_publish.yml): manual workflow to publish pip package - used for pushing dev releases * ci: remove redundant file --- .github/workflows/README.md | 35 ++++++++++++ .github/workflows/simple_pypi_publish.yml | 67 +++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/simple_pypi_publish.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000000..b4e777969d9 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,35 @@ +# Simple PyPI Publishing + +A GitHub workflow to manually publish LiteLLM packages to PyPI with a specified version. + +## How to Use + +1. Go to the **Actions** tab in the GitHub repository +2. Select **Simple PyPI Publish** from the workflow list +3. Click **Run workflow** +4. Enter the version to publish (e.g., `1.74.10`) + +## What the Workflow Does + +1. **Updates** the version in `pyproject.toml` +2. **Copies** the model prices backup file +3. **Builds** the Python package +4. **Publishes** to PyPI + +## Prerequisites + +Make sure the following secret is configured in the repository: +- `PYPI_PUBLISH_PASSWORD`: PyPI API token for authentication + +## Example Usage + +- Version: `1.74.11` → Publishes as v1.74.11 +- Version: `1.74.10-hotfix1` → Publishes as v1.74.10-hotfix1 + +## Features + +- ✅ Manual trigger with version input +- ✅ Automatic version updates in `pyproject.toml` +- ✅ Repository safety check (only runs on official repo) +- ✅ Clean package building and publishing +- ✅ Success confirmation with PyPI package link \ No newline at end of file diff --git a/.github/workflows/simple_pypi_publish.yml b/.github/workflows/simple_pypi_publish.yml new file mode 100644 index 00000000000..e1830556819 --- /dev/null +++ b/.github/workflows/simple_pypi_publish.yml @@ -0,0 +1,67 @@ +name: Simple PyPI Publish + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to publish (e.g., 1.74.10)' + required: true + type: string + +env: + TWINE_USERNAME: __token__ + +jobs: + publish: + runs-on: ubuntu-latest + if: github.repository == 'BerriAI/litellm' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install toml build wheel twine + + - name: Update version in pyproject.toml + run: | + python -c " + import toml + + with open('pyproject.toml', 'r') as f: + data = toml.load(f) + + data['tool']['poetry']['version'] = '${{ github.event.inputs.version }}' + + with open('pyproject.toml', 'w') as f: + toml.dump(data, f) + + print(f'Updated version to ${{ github.event.inputs.version }}') + " + + - name: Copy model prices file + run: | + cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json + + - name: Build package + run: | + rm -rf build dist + python -m build + + - name: Publish to PyPI + env: + TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_PASSWORD }} + run: | + twine upload dist/* + + - name: Output success + run: | + echo "✅ Successfully published litellm v${{ github.event.inputs.version }} to PyPI" + echo "📦 Package: https://pypi.org/project/litellm/${{ github.event.inputs.version }}/" \ No newline at end of file