Skip to content

Python package build and publish #65

Python package build and publish

Python package build and publish #65

Workflow file for this run

name: Python package build and publish
on:
release:
types: [created]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine
- name: Build wheels on Ubuntu
if: matrix.os == 'ubuntu-latest'
uses: RalfG/[email protected]_x86_64
with:
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
build-requirements: 'cython numpy'
- name: Build wheels on Windows
if: matrix.os == 'windows-latest'
run: |
pip install cibuildwheel
cibuildwheel --output-dir dist
# You may need to adjust the above command based on your package's specific requirements
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/[email protected]
with:
path: dist
- name: Move wheel files to 'dist' directory
run: |
find dist -name '*.whl' -exec mv {} dist \;
- name: Check for wheel types
id: check_wheels
run: |
echo "Checking for wheel types..."
if ls dist/*-manylinux*.whl 1> /dev/null 2>&1; then
echo "Found manylinux wheels."
echo "HAS_MANYLINUX_WHEELS=true" >> $GITHUB_ENV
fi
if ls dist/*-win_*.whl 1> /dev/null 2>&1; then
echo "Found Windows wheels."
echo "HAS_WINDOWS_WHEELS=true" >> $GITHUB_ENV
fi
- name: List files in dist
run: ls -l dist
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install twine
run: pip install twine
- name: Publish manylinux wheels to Production PyPI
if: env.HAS_MANYLINUX_WHEELS == 'true'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }}
run: twine upload dist/*-manylinux*.whl
- name: Publish Windows wheels to Production PyPI
if: env.HAS_WINDOWS_WHEELS == 'true'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }}
run: twine upload dist/*-win_*.whl