Skip to content

Upload Python SDK Package #1

Upload Python SDK Package

Upload Python SDK Package #1

name: Upload Python SDK Package
on:
workflow_dispatch:
inputs:
publish:
description: "Publish Python SDK to PyPI"
required: false
default: "false"
permissions:
contents: read
packages: write
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Build release distributions
run: |
python -m pip install --upgrade pip build
python -m build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
needs: release-build
permissions:
contents: read
packages: write
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Conditional Publish
if: ${{ inputs.publish == 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}