Skip to content

Commit

Permalink
Add CI files to build python packages
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Dec 17, 2024
1 parent 7b091ff commit b4a0d51
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# From https://github.com/wjakob/nanobind_example/blob/5ce5ce57143a469e92d9ebaee9c47949ee77caa8/.github/workflows/pip.yml
name: Pip

on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
build:
name: Build with Pip
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, ubuntu-latest]
python-version: ["3.8", "3.12"]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set min macOS version
if: runner.os == 'macOS'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV
- name: Build and install
run: |
python -m pip install pytest
pip install --verbose .
- name: Test
run: python -m pytest
78 changes: 78 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# From https://github.com/wjakob/nanobind_example/blob/5ce5ce57143a469e92d9ebaee9c47949ee77caa8/.github/workflows/wheels.yml

name: Wheels

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
release:
types:
- published

jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build SDist
run: pipx run build --sdist

- name: Check metadata
run: pipx run twine check dist/*

- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*.tar.gz


build_wheels:
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: pypa/[email protected]

- name: Verify clean directory
run: git diff --exit-code
shell: bash

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

upload_all:
name: Upload if release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/setup-python@v5
- uses: actions/download-artifact@v4
with:
name: dist
pattern: dist-*
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}

0 comments on commit b4a0d51

Please sign in to comment.