Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a github action workflow to upload to PyPI #57

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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/