Skip to content

Commit

Permalink
feat: add pre-built wheels (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Feb 25, 2025
1 parent ddb7fc8 commit 5d0d7ed
Showing 1 changed file with 93 additions and 15 deletions.
108 changes: 93 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: "3.11"
- uses: pre-commit/action@v3.0.1

# Make sure commit messages follow the conventional commits convention:
Expand All @@ -36,40 +36,37 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest
- macOS-latest
extension:
- "skip_cython"
- "use_cython"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: snok/install-poetry@v1.4.1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
allow-prereleases: true
- name: Install Dependencies no cython
if: ${{ matrix.extension == 'skip_cython' }}
env:
SKIP_CYTHON: 1
run: poetry install --only=main,dev
- name: Install Dependencies with cython
if: ${{ matrix.extension != 'skip_cython' }}
env:
REQUIRE_CYTHON: 1
run: poetry install --only=main,dev
- name: Install Dependencies
run: |
if [ "${{ matrix.extension }}" = "skip_cython" ]; then
SKIP_CYTHON=1 poetry install --only=main,dev
else
REQUIRE_CYTHON=1 poetry install --only=main,dev
fi
shell: bash
- name: Test with Pytest
run: poetry run pytest --durations=20 -v --cov=src --cov-branch --cov-report xml --cov-report html --cov-report term-missing tests
shell: bash
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
Expand All @@ -87,6 +84,9 @@ jobs:
permissions:
id-token: write
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
newest_release_tag: ${{ steps.release_tag.outputs.newest_release_tag }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -118,3 +118,81 @@ jobs:
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install python-semantic-release
run: python3 -m pip install python-semantic-release==7.34.6

- name: Get Release Tag
id: release_tag
shell: bash
run: |
echo "newest_release_tag=$(semantic-release print-version --current)" >> $GITHUB_OUTPUT
build_wheels:
needs: [release]
if: needs.release.outputs.released == 'true'

name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-24.04-arm
- macos-13
- macos-latest
- ubuntu-latest
- windows-latest
musl: ["", "musllinux"]
exclude:
- os: windows-latest
musl: "musllinux"
- os: macos-latest
musl: "musllinux"
- os: macos-13
musl: "musllinux"
steps:
- uses: actions/checkout@v4
with:
ref: "v${{ needs.release.outputs.newest_release_tag }}"
fetch-depth: 0

# Used to host cibuildwheel
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
# to supply options, put them in 'env', like:
env:
CIBW_SKIP: cp36-* cp37-* cp38-* pp36-* pp37-* pp38-* ${{ matrix.musl == 'musllinux' && '*manylinux*' || '*musllinux*' }}
CIBW_BEFORE_ALL_LINUX: apt-get install -y gcc || yum install -y gcc || apk add gcc
CIBW_BUILD_VERBOSITY: 3
REQUIRE_CYTHON: 1
CIBW_ARCHS_LINUX: ${{ matrix.os == 'ubuntu-24.04-arm' && 'aarch64' || 'auto' }}

- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}-${{ matrix.musl }}

upload_pypi:
needs: [build_wheels]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
path: dist
pattern: wheels-*
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@v1.12.4

0 comments on commit 5d0d7ed

Please sign in to comment.