Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release Python SDK

on:
push:
tags:
- "release/v*"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: python-release-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
name: Build and publish to PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install dependencies
run: |
set -euo pipefail

python -m pip install --upgrade pip
python -m pip install build twine pytest

if [ -f requirements.txt ]; then
python -m pip install -r requirements.txt
fi

- name: Build package
run: |
set -euo pipefail

rm -rf dist build *.egg-info

python -m build

if [ ! -d dist ] || [ -z "$(ls -A dist/)" ]; then
echo "Error: Build failed - no distributions created"
exit 1
fi

ls -lh dist/

- name: Validate package
run: |
set -euo pipefail

python -m twine check dist/*

- name: Validate PyPI token
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
set -euo pipefail

if [ -z "${PYPI_API_TOKEN:-}" ]; then
echo "Error: PYPI_API_TOKEN secret not configured"
exit 1
fi

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}