Skip to content

Upload Python Package to PyPI #11

Upload Python Package to PyPI

Upload Python Package to PyPI #11

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package to PyPI
on:
workflow_dispatch:
# Right now, boolean inputs are broken. this can be reenabled when this is fixed
# inputs:
# isTest:
# description: Should the package be pushed to TestPyPI?
# type: boolean
# required: false
# default: false
jobs:
build-and-publish:
name: Build and Publish Python Package to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary whell and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution to PyPI
# if: ${{ !github.event.inputs.isTest }} && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# Enable if you want to publish to TestPyPI
# - name: Publish distribution to Test PyPI
# if: ${{ github.event.inputs.isTest }}
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/