Skip to content

Publish Python SDK to PyPI #5

Publish Python SDK to PyPI

Publish Python SDK to PyPI #5

name: Publish Python SDK to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
temp_version:
description: 'Optional version override (ex: 0.1.0-test)'
required: false
default: ''
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for trusted publishing to PyPI
env:
TEMP_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.temp_version || '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Override Python package version for testing
if: env.TEMP_VERSION != ''
run: |
sed -i.bak "s/^version = \".*\"/version = \"$TEMP_VERSION\"/" pyproject.toml
- name: Install Python build tools
run: pip install build
- name: Build Python package
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1