Skip to content

ortega2247/pypi-upload-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Action to release a python package to PyPI

This action uploads python distribution packages located in the dist/ directory to PyPI.

This action assumes that a python environment is set up. Python can be set up with conda as well

Usage

Upload packages to PyPI

- name: Publish a Python distribution to PyPI
  uses: ortega2247/pypi-upload-action@master
  with:
    user: __token__
    password: ${{ secrets.pypi_password }}

To upload packages to TestPyPI

- name: Publish a Python distribution to PyPI
  uses: ortega2247/pypi-upload-action@master
  with:
    user: __token__
    password: ${{ secrets.test_pypi_password }}
    repository_url: https://test.pypi.org/legacy/

If python distribution packages are located in a directory other than dist

- name: Publish a Python distribution to PyPI
  uses: ortega2247/pypi-upload-action@master
  with:
    user: __token__
    password: ${{ secrets.test_pypi_password }}
    repository_url: https://test.pypi.org/legacy/
    packages_dir: my_directory

Limit releases to tagged pushes

- name: Publish a Python distribution to PyPI
  if: startsWith(github.ref, 'refs/tags/')
  uses: ortega2247/pypi-upload-action@master
  with:
    user: __token__
    password: ${{ secrets.test_pypi_password }}
    repository_url: https://test.pypi.org/legacy/
    packages_dir: my_directory

To use this action you need to get an API token from PyPI. Then, use this token to create a GitHub secret