Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, Build, and Deploy to PyPI (Linux only) | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
permissions: | |
contents: read | |
pull-requests: read | |
jobs: | |
test: | |
strategy: | |
matrix: | |
python: ['3.9', '3.10', '3.11', '3.12'] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install . | |
- name: Run Tests | |
run: pytest tests/ | |
build: | |
needs: test # Ensure tests complete successfully before building | |
if: github.event_name == 'release' | |
strategy: | |
matrix: | |
python: ['3.9', '3.10', '3.11', '3.12'] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Build Tools | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel build twine | |
- name: Clean dist directory | |
run: rm -rf dist | |
- name: Build Package | |
run: python -m build | |
- name: List dist contents | |
run: ls -R dist | |
- name: Validate Distribution Files | |
run: twine check dist/*.whl dist/*.tar.gz | |
- name: Archive Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-artifacts | |
path: dist/*.whl dist/*.tar.gz | |
deploy: | |
needs: build # Ensure build completes before deploying | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set Up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Twine | |
run: | | |
python -m pip install --upgrade pip | |
pip install twine | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-artifacts | |
path: dist | |
- name: Validate Distribution Files | |
run: twine check dist/*.whl dist/*.tar.gz | |
- name: Upload to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: twine upload dist/*.whl dist/*.tar.gz |