Skip to content

Publish to PyPI

Publish to PyPI #2

Workflow file for this run

name: Publish to PyPI
on:
release:
types: [published]
workflow_dispatch: # Allow manual triggering
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout code
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>=7.0.0 pytest-cov>=4.0.0 pytest-mock>=3.10.0 pytest-asyncio>=0.21.0
pip install black>=22.0.0 flake8>=5.0.0 mypy>=1.0.0 isort>=5.10.0
pip install pre-commit>=2.20.0 tox>=4.0.0
- name: Run tests
run: |
python run_tests.py
- name: Run linting
run: |
pip install flake8
flake8 src/ tests/
publish:
needs: test
runs-on: ubuntu-latest
environment: pypi # This matches the environment name in PyPI config
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Verify installation
run: |
pip install nendb --index-url https://pypi.org/simple/
python -c "import nendb; print(f'Successfully installed nendb version {nendb.__version__}')"