Skip to content

Add a GitHub Actions workflow for automatic PyPi publishing whenever creating a new release #2

Add a GitHub Actions workflow for automatic PyPi publishing whenever creating a new release

Add a GitHub Actions workflow for automatic PyPi publishing whenever creating a new release #2

Workflow file for this run

name: Publish to PyPi
on:
release:
types: [published]
pull_request: # for testing... to remove...
types: [ opened, synchronize, reopened ]
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
pip install setuptools wheel twine
- name: Build and install package
run: |
python setup.py sdist bdist_wheel
pip install dist/*.whl
- name: Run Unit Tests
run: |
pytest unit_tests
build-and-publish:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}