Skip to content

Publish Python package to PyPI #9

Publish Python package to PyPI

Publish Python package to PyPI #9

Workflow file for this run

name: Publish Python package to PyPI
on:
release:
types: [published]
jobs:
build_dist:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: python -m pip install --upgrade pip && pip install build
- name: Build
run: python -m build
- uses: actions/upload-artifact@v4
with:
name: build
path: dist/*
upload:
needs: [build_dist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: build
path: dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.8.12
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/
- name: Publish to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@v1.8.12
with:
packages-dir: dist/