Skip to content

A Github Action to publish your Python package to PyPI or any other repository.

License

Notifications You must be signed in to change notification settings

mariamrf/py-package-publish-action

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Publish Python Package

A Github Action to build and publish your Python package to PyPI or any other repository. Supports any Python version you'll give it (that is also supported by pyenv).

Use

Pre-requisites

In order for the Action to have access to the code, you must use the actions/checkout@master job before it. See the example below.

Environment Variables/Secrets

  • Login credentials for the package repo (as specified by twine). So, for example:
    • TWINE_USERNAME=scott
    • TWINE_PASSWORD=tiger etc.
      This would also be where you'd set TWINE_REPOSITORY_URL if publishing to something other than PyPI.

Inputs

  • python_version: a Python version that is supported by pyenv. For example: 3.7.0.
  • pip_version (optional): the pip version to use (defaults to newest), some packages may require different pip versions.
  • subdir (optional): if your setup.py (and therefore, your entire package) is in a subdirectory of your repo, put the path to it here. This will just change the working directory to the SUBDIR before running the rest of the script.

Example workflow

name: publish-pypi

on:
  push:
    branches:
      - master

jobs:
  build:

    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@master
    - name: Publish Python Package
      uses: mariamrf/py-package-publish-action@v1.0.0
      with:
        python_version: '3.6.0'
      env:
        TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
        TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}