Skip to content

Merge pull request #11 from aashishvanand/main #3

Merge pull request #11 from aashishvanand/main

Merge pull request #11 from aashishvanand/main #3

Workflow file for this run

# Build and publish Python package - runs only on release branch and GitHub releases
name: Publish Python Package
on:
push:
branches:
- release
release:
types: [published]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest==8.3.4 pytest-cov==6.0.0
pip install -e .
- name: Verify package installation
run: |
python -c "import airports.airport_data; print('Package imported successfully')"
python -c "from airports import airport_data; print(f'Loaded {len(airport_data.airports)} airports')"
- name: Run tests
run: |
python -m pytest tests/ -v --cov=airports --cov-report=xml
build:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: '3.x'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build==1.2.2 twine==6.0.1
- name: Check for airports data file
run: |
if [ ! -f "airports/data/airports.gz" ]; then
echo "Missing airports.gz file"
echo "This file is required for the package to work."
echo "Please ensure airports/data/airports.gz exists before publishing."
exit 1
else
echo "Found airports.gz file"
python scripts/generate_airports_gz.py --verify-only
fi
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: List package contents
run: |
echo "Package contents:"
tar -tzf dist/*.tar.gz | head -20
echo "..."
echo "Package built successfully"
- name: Upload build artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: python-package-distributions
path: dist/
publish-to-testpypi:
name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch'
needs: [test, build]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment:
name: testpypi
url: https://test.pypi.org/p/airports-py
steps:
- name: Download build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8
with:
name: python-package-distributions
path: dist/
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
print-hash: true
publish-to-pypi:
name: Publish to PyPI
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/release')
needs: [test, build]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment:
name: pypi
url: https://pypi.org/p/airports-py
steps:
- name: Download build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8
with:
name: python-package-distributions
path: dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0