Skip to content

Add a workflow to build, test and upload sdist and universal wheels #104

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

Merged
merged 1 commit into from
Nov 4, 2020
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
96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Upload Python Package

on:
push:
tags:
- "v*"
branches:
- master

jobs:
build_sdist:
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
pip install -U setuptools wheel build
- name: Build
run: |
python -m build --sdist --outdir dist/ .
- name: Install
run: |
pip install dist/
- name: Run tests
run: |
pytest tests
pytest tests --mpl
- name: Store sdist
uses: actions/upload-artifact@v2
with:
name: sdist
path: |
dist/*

build_universal_wheel:
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
pip install -U setuptools wheel build
- name: Build
run: |
python -m build --sdist --outdir dist/ .
- name: Install
run: |
pip install dist/
- name: Run tests
run: |
pytest tests
pytest tests --mpl
- name: Store sdist
uses: actions/upload-artifact@v2
with:
name: sdist
path: |
dist/*

upload:
runs-on: ubuntu-latest
# Only upload on a tag
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- build_universal_wheel
- build_sdist
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
pip install -U setuptools wheel twine

- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
path: dist/
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*