This guide will help you set up the automated SDK generation and publishing pipeline.
The Python SDK is automatically:
- Generated from the OpenAPI specification at
https://server-xb24.onrender.com/docs/openapi.json - Published to PyPI when the API version changes
- Tagged and released on GitHub
- GitHub account with access to both
mixpeek/serverandmixpeek/python-sdkrepositories - PyPI account with API token
- npm installed (for openapi-generator-cli)
- Go to pypi.org and create an account
- Verify your email address
- Go to pypi.org/manage/account/token/
- Click "Add API token"
- Name it:
mixpeek-python-sdk - Scope: Select "Project: mixpeek" (or "Entire account" if the project doesn't exist yet)
- Click "Add token"
- IMPORTANT: Copy the token immediately (it starts with
pypi-)
- Go to the
mixpeek/python-sdkrepository on GitHub - Navigate to: Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
PYPI_API_TOKEN - Value: Paste the PyPI token you copied
- Click "Add secret"
- Go to GitHub: Settings → Developer settings → Personal access tokens → Fine-grained tokens
- Click "Generate new token"
- Configure:
- Token name:
mixpeek-sdk-trigger - Expiration: 1 year (or your preference)
- Repository access: Only select repositories
- Select:
mixpeek/python-sdk
- Select:
- Repository permissions:
- Contents: Read and write
- Actions: Read and write
- Workflows: Read and write
- Token name:
- Click "Generate token"
- IMPORTANT: Copy the token immediately (starts with
github_pat_)
- Go to the
mixpeek/serverrepository on GitHub - Navigate to: Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
SDK_TRIGGER_TOKEN - Value: Paste the PAT you copied
- Click "Add secret"
Create a file at .github/workflows/trigger-sdk-update.yml in the server repository:
name: Trigger SDK Update
on:
push:
branches:
- main
paths:
- 'app/**' # Adjust to your API code path
- 'openapi.json' # If you have a static OpenAPI file
# Manual trigger
workflow_dispatch:
jobs:
trigger-sdk-generation:
runs-on: ubuntu-latest
steps:
- name: Trigger Python SDK Update
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.SDK_TRIGGER_TOKEN }}" \
https://api.github.com/repos/mixpeek/python-sdk/dispatches \
-d '{"event_type":"openapi-update"}'
- name: Notify
run: |
echo "✅ Triggered Python SDK regeneration"- Go to the
mixpeek/python-sdkrepository - Navigate to: Actions → Sync OpenAPI and Publish to PyPI
- Click "Run workflow" dropdown
- Select branch:
main - Click "Run workflow"
- Watch the workflow run and verify it completes successfully
- Make a small change to your server API code
- Commit and push to the
mainbranch ofmixpeek/server - Check the Actions tab in both repositories:
mixpeek/server: Should show "Trigger SDK Update" workflowmixpeek/python-sdk: Should show "Sync OpenAPI and Publish to PyPI" workflow
- After completion, check:
- PyPI for the new version
- GitHub Releases for the new tag
Server Repo (main branch)
↓
Push to main
↓
GitHub Actions: trigger-sdk-update.yml
↓
Repository Dispatch Event
↓
Python SDK Repo
↓
GitHub Actions: sync-and-publish.yml
↓
1. Download OpenAPI spec
2. Extract version
3. Check if version exists on PyPI
4. Generate SDK (if new version)
5. Build package
6. Publish to PyPI
7. Create GitHub Release
- The version is automatically extracted from the OpenAPI spec's
info.versionfield - If the version already exists on PyPI, the workflow skips publishing
- To publish a new version, update the version in your OpenAPI spec
# Clone the repository
git clone https://github.com/mixpeek/python-sdk.git
cd python-sdk
# Run the generation script
./generate.sh# Install in development mode
pip install -e .
# Run tests
python -m pytest test/
# Test imports
python -c "import mixpeek; print(mixpeek.__version__)"# Build the package
python -m build
# Test installation from local wheel
pip install dist/mixpeek-*.whl
# Verify
python -c "import mixpeek; print('✅ SDK installed successfully')"Solution: The workflow automatically skips publishing if the version exists. Update the version in your OpenAPI spec.
Solution:
- Verify the
PYPI_API_TOKENsecret is correctly set - Regenerate the token on PyPI if needed
- Update the secret in GitHub
Solution:
- Verify the
SDK_TRIGGER_TOKENhas correct permissions - Check the token hasn't expired
- Verify the repository name in the curl command is correct
Solution:
- Check the OpenAPI spec is valid JSON
- Verify the OpenAPI spec URL is accessible
- Look at the workflow logs for specific errors
Solution:
- Check Python syntax in generated code
- Verify all dependencies are listed in requirements.txt
- Check for linting errors
- Package Page: pypi.org/project/mixpeek/
- Download Stats: Available on PyPI package page
Edit .github/workflows/sync-and-publish.yml in the python-sdk repository:
# Change generator settings
openapi-generator-cli generate \
-i openapi-cleaned.json \
-g python \
--additional-properties=packageVersion=$VERSION,...Edit .github/workflows/trigger-sdk-update.yml in the server repository:
on:
push:
branches:
- main
- develop # Add more branches
release:
types: [published] # Trigger on release- Version Bumping: Always bump the version in your OpenAPI spec when making API changes
- Semantic Versioning: Follow semver for version numbers
- Testing: Test the SDK locally before relying on auto-publish
- Documentation: Update API documentation when adding new endpoints
- Breaking Changes: Use major version bumps for breaking changes
For issues with:
- Setup: Check this guide or open an issue on GitHub
- SDK Generation: Check OpenAPI spec validity
- Publishing: Verify PyPI token and permissions
- Automation: Check GitHub Actions logs
Last Updated: October 2025