Skip to content

Workflow file for this run

name: Upload package
on:
push:
branches:
- 'publish'
tags:
- '*'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U build twine
- name: Build package
run: |
python -m build
- name: Publish package
env:
TWINE_USERNAME: "__token__"
run: |
if [[ $GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
export TWINE_REPOSITORY_URL="testpypi"
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
export TWINE_REPOSITORY="pypi"
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
else
echo "Unknown event name: ${GITHUB_EVENT_NAME}"
exit 1
fi
python -m twine upload dist/*