Build and upload PyPI wheels and source dist #65
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: Build and upload PyPI wheels and source dist | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11'] | |
include: | |
- os: windows-latest | |
wheelname: win | |
- os: macos-latest | |
wheelname: macos | |
- os: ubuntu-latest | |
wheelname: manylinux | |
# Build wheels against the lowest compatible Numpy version | |
- python-version: 3.8 | |
manylinux-version-tag: cp38 | |
numpy-version: 1.19.5 | |
- python-version: 3.9 | |
manylinux-version-tag: cp39 | |
numpy-version: 1.19.5 | |
- python-version: 3.10 | |
manylinux-version-tag: cp310 | |
numpy-version: 1.21.3 | |
- python-version: 3.11 | |
manylinux-version-tag: cp311 | |
numpy-version: 1.23.2 | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: v1.3.1 | |
fetch-depth: 0 # Ensure tags are fetched for versioning | |
- name: Setup Python ${{ matrix.python-version }} with Conda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
channels: conda-forge,defaults | |
channel-priority: true | |
- name: Update Python pip, wheel, and twine | |
shell: bash -l {0} | |
run: | | |
python -m pip install --upgrade pip wheel twine | |
- name: Install llvm on Macos | |
if: startsWith(matrix.os, 'macos') | |
run: brew install llvm | |
- name: Build Python wheel | |
if: matrix.os != 'ubuntu-latest' | |
shell: bash -l {0} | |
env: | |
NUMPY_VERSION: ${{ matrix.numpy-version }} | |
run: | | |
# Build against lowest required Numpy version | |
python -m pip install numpy==${NUMPY_VERSION} | |
python -m pip wheel . -w wheelhouse --no-deps | |
- name: Build manylinux Python wheel | |
if: matrix.os == 'ubuntu-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ matrix.manylinux-version-tag}}-manylinux* | |
CIBW_BEFORE_BUILD: python -mpip install numpy==${{ matrix.numpy-version }} | |
CIBW_ARCHS: x86_64 | |
with: | |
output-dir: wheelhouse | |
- name: Create source distribution | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
shell: bash -l {0} | |
run: | | |
python setup.py sdist | |
- name: Upload source dist as build artifact | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' # && github.event_name == 'release' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-source-distribution | |
path: dist | |
- name: Upload wheels as build artifacts | |
if: matrix.os == 'windows-latest' || (matrix.os == 'macos-latest' && matrix.python-version != '3.10') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }} | |
path: wheelhouse/*-${{ matrix.wheelname }}*.whl | |
publish: | |
# if: github.event_name == 'release' | |
needs: build | |
name: Upload release to PyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/euphonic | |
permissions: | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: v1.3.1 | |
fetch-depth: 0 # This is possibly unnecessary? | |
- name: Download artifacts to Ubuntu environment | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist/ | |
merge-multiple: true | |
- name: List Files | |
run: ls -R | |
- name: Upload wheels to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |