Skip to content

Commit

Permalink
Add GitHub actions for CI and deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinse committed Apr 15, 2023
1 parent af71483 commit 9406fa7
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.x"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install .[test,dist]
- name: Test with pytest
run: |
pytest -v
52 changes: 52 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.x"]

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install build
- name: Build 2.7 package
if: ${{ matrix.python-version == '2.7' }}
run: python -m build --wheel
- name: Build package
if: ${{ matrix.python-version != '2.7' }}
run: python -m build
# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
#'Programming Language :: Python :: 3 :: Only',
],

Expand Down Expand Up @@ -159,7 +160,7 @@
# projects.
extras_require={ # Optional
'dist': ['build'],
'dev': ['pylint', 'flake8', 'mypy'],
'lint': ['pylint', 'flake8', 'mypy'],
'test': ['pytest', 'coverage', 'pytest-cov', 'pytest-mock', 'attrs'],
},

Expand Down

0 comments on commit 9406fa7

Please sign in to comment.