Build and publish package to PyPI #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish package to PyPI | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
inputs: | |
target: | |
description: 'Deployment target. Can be "pypi" or "testpypi"' | |
default: "pypi" | |
jobs: | |
publish_pypi: | |
name: Build wheels on ubuntu-latest | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python -m build | |
- name: Publish on PyPI | |
if: github.event.inputs.target == 'pypi' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Publish on TestPyPI | |
if: github.event.inputs.target == 'testpypi' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ |