Skip to content

Publish Package To PyPi #14

Publish Package To PyPi

Publish Package To PyPi #14

Workflow file for this run

name: Publish Package
on:
release:
types: [published]
jobs:
Release-nature:
runs-on: ubuntu-latest
steps:
- name: Check release type
run: |
if [ "${{ github.event.action }}" == "published" ]; then
echo "This is a stable release."
elif [ "${{ github.event.action }}" == "prereleased" ]; then
echo "This is a prerelease."
else
echo "Unexpected release action."
fi
Lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install linting dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --only lint
- name: Run flake8
run: |
poetry run flake8 pyfilehandling
Test:
runs-on: ${{ matrix.os }}
needs: Lint
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macOS-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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
pip install poetry
poetry install
- name: Run pytest with coverage
run: |
poetry run coverage run -m pytest
poetry run coverage report --fail-under=50
Publish:
runs-on: ubuntu-latest
needs: [Test, Release-nature]
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --no-root
- name: Update Poetry
run: |
pip install --upgrade poetry
- name: Debugging Output
run: |
cat pyproject.toml
- name: Build distribution and publish to PyPI
env:
POETRY_PYPI_USERNAME: ${{ secrets.POETRY_PYPI_USERNAME }}
POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }}
run: |
poetry publish --build --username $POETRY_PYPI_USERNAME --password $POETRY_PYPI_TOKEN