-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
110c689
commit b44be3d
Showing
3 changed files
with
241 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: Release and Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: "recursive" | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Install cibuildwheel | ||
run: python -m pip install cibuildwheel | ||
|
||
- name: Install system dependencies (Ubuntu) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y \ | ||
python3-dev \ | ||
pybind11-dev \ | ||
ninja-build \ | ||
cmake \ | ||
build-essential | ||
- name: Install system dependencies (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install \ | ||
pybind11 \ | ||
ninja \ | ||
cmake | ||
- name: Install system dependencies (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
choco install ninja cmake | ||
pip install pybind11 | ||
# Build wheels | ||
- name: Build wheels | ||
env: | ||
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" # Python versions to build for | ||
CIBW_SKIP: "*-win32 *-manylinux_i686" # Skip 32-bit builds | ||
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 # Use manylinux2014 for better compatibility | ||
CIBW_BEFORE_BUILD_LINUX: "yum install -y pybind11-devel ninja-build" | ||
CIBW_TEST_REQUIRES: "pytest numpy" | ||
CIBW_TEST_COMMAND: "pytest {project}/python/tests -v" | ||
run: | | ||
python -m cibuildwheel --output-dir wheelhouse | ||
- name: Build source distribution | ||
if: runner.os == 'Linux' # Only need to build sdist once | ||
run: | | ||
pip install build | ||
python -m build --sdist | ||
- name: Upload wheels as artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels-${{ matrix.os }} | ||
path: | | ||
./wheelhouse/*.whl | ||
./dist/*.tar.gz | ||
create_release: | ||
needs: build_wheels | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: dist | ||
|
||
- name: Prepare release assets | ||
run: | | ||
mkdir -p release_assets | ||
cp dist/*/*.whl release_assets/ | ||
cp dist/*/*.tar.gz release_assets/ || true # sdist might not exist in all artifacts | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
Release ${{ github.ref }} | ||
Wheels available for: | ||
- Linux (x86_64) | ||
- macOS (x86_64, arm64) | ||
- Windows (x86_64) | ||
Python versions: | ||
- 3.8 | ||
- 3.9 | ||
- 3.10 | ||
- 3.11 | ||
- 3.12 | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Assets | ||
run: | | ||
for asset in release_assets/*; do | ||
asset_name=$(basename "$asset") | ||
curl \ | ||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ | ||
-H "Content-Type: application/octet-stream" \ | ||
--data-binary "@$asset" \ | ||
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=$asset_name" | ||
done | ||
publish_pypi: | ||
needs: create_release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: dist | ||
|
||
- name: Prepare distribution files | ||
run: | | ||
mkdir -p dist_final | ||
cp dist/*/*.whl dist_final/ | ||
cp dist/*/*.tar.gz dist_final/ || true | ||
- name: Publish to PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: | | ||
pip install twine | ||
twine upload dist_final/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build-and-test: | ||
name: Build and Test on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: "recursive" # For Google Test | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install system dependencies (Ubuntu) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y \ | ||
python3-dev \ | ||
pybind11-dev \ | ||
ninja-build \ | ||
cmake \ | ||
build-essential | ||
- name: Install system dependencies (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install \ | ||
pybind11 \ | ||
ninja \ | ||
cmake | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest meson meson-python ninja numpy | ||
- name: Configure Meson | ||
run: meson setup build | ||
|
||
- name: Build | ||
run: meson compile -C build | ||
|
||
- name: Run C++ Tests | ||
run: meson test -C build -v | ||
|
||
- name: Install Python Package | ||
run: pip install -e . | ||
|
||
- name: Run Python Tests | ||
run: pytest python/tests -v | ||
|
||
- name: Upload Test Results | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }} | ||
path: | | ||
build/meson-logs/testlog.txt | ||
build/meson-logs/meson-log.txt |
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