Skip to content

Build and publish to PyPI #27

Build and publish to PyPI

Build and publish to PyPI #27

Workflow file for this run

name: Build and publish to PyPI
on:
release:
types: [published]
jobs:
build-and-publish:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build wheel and source distribution
run: python -m build
- name: Check distribution
run: |
ls -la dist/
python -m twine check dist/*
- name: Test installation
run: |
python -m pip install dist/*.whl
python -c "import site_analysis; print(f'✅ site-analysis {site_analysis.__version__} imported successfully')"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1