Twine distribution checks #16
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 PYPIP | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
permissions: | |
contents: read | |
pull-requests: read | |
jobs: | |
test: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python: ['3.9', '3.10', '3.11', '3.12'] | |
runs-on: ${{ matrix.os }} | |
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 e . | |
- name: Run Tests | |
run: | | |
pytest tests/ | |
build: | |
if: github.event_name == 'release' | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python: ['3.9', '3.10', '3.11', '3.12'] | |
runs-on: ${{ matrix.os }} | |
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: Archive Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifacts-${{ matrix.os }}-${{ matrix.python }} | |
path: dist | |
deploy: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
needs: build | |
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: | |
path: dist | |
- name: Validate Distribution Files | |
run: twine check dist/* | |
- name: Upload to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
twine upload dist/*.whl dist/*.tar.gz |