Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Python SDK Release

Python SDK Release #31

Workflow file for this run

name: Python SDK Release
on:
workflow_dispatch:
inputs:
dryrun:
description: "Dry run mode: do not publish or release"
required: false
default: "true"
env:
PACKAGE_PATH: .
jobs:
build_release_deploy:
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: [ self-hosted, Linux, X64 ]
environment: Release
permissions:
contents: write
steps:
- name: Extract version from branch name
id: extract_version
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/release/}"
echo "Detected version: $BRANCH_NAME"
# Validate SemVer (including optional pre-release like -dev0)
if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "version=$BRANCH_NAME" >> $GITHUB_OUTPUT
else
echo "Invalid branch name: must match release/{semver}"
exit 1
fi
- name: Checkout code
uses: actions/checkout@v3
- name: Update Version in pyproject.toml
run: |
sed -i "s/^version = .*/version = \"${{ steps.extract_version.outputs.version }}\"/" "$PACKAGE_PATH/pyproject.toml"
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install build and release dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build Wheel
run: |
cd "$PACKAGE_PATH"
python -m build
- name: Determine Wheel Filename
id: wheel
shell: bash
run: echo "wheel=$(ls dist/*.whl | xargs -n 1 basename)" >> $GITHUB_OUTPUT
- name: Publish to PyPI
if: ${{ github.event.inputs.dryrun != 'true' }}
run: |
cd "$PACKAGE_PATH"
python -m twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN_MAKE87 }}
- name: Build Documentation
run: |
python -m pip install -e .
cd docs
python -m pip install -r requirements.txt
mkdocs build
- name: Create GitHub Release
if: ${{ github.event.inputs.dryrun != 'true' }}
uses: ncipollo/release-action@v1
with:
artifacts: "${{ env.PACKAGE_PATH }}/dist/${{ steps.wheel.outputs.wheel }}"
tag: release/${{ steps.extract_version.outputs.version }}
name: Python SDK ${{ steps.extract_version.outputs.version }}
removeArtifacts: true
omitBody: true
allowUpdates: true
- name: Deploy Documentation to Netlify
if: ${{ github.event.inputs.dryrun != 'true' }}
uses: nwtgck/actions-netlify@v3.0.0
with:
publish-dir: "docs/site"
deploy-message: "Deploy Python SDK Documentation ${{ steps.extract_version.outputs.version }} via GitHub Actions."
production-deploy: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_DOCS_DEPLOY_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DOCS_PYTHON_DEPLOY_SITE }}