Skip to content

Upload Python Package #11

Upload Python Package

Upload Python Package #11

Workflow file for this run

name: Upload Python Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
repository:
description: 'Repository'
required: true
default: 'PYPI'
type: choice
options:
- 'PYPI'
- 'TEST_PYPI'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r test-requirements.txt
- name: Test package
run: |
python3 -m pip install -e .
pytest --verbose
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install wheel
- name: Build package
run: |
python3 setup.py sdist bdist_wheel
- name: Publish to PyPI
if: ${{ github.event.inputs.repository == 'PYPI' || github.event.inputs.repository == '' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish to test PyPI
if: ${{ github.event.inputs.repository == 'TEST_PYPI' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/