Skip to content

fix(ci): Fix Eigen3 version compatibility and macOS runner in publish… #5

fix(ci): Fix Eigen3 version compatibility and macOS runner in publish…

fix(ci): Fix Eigen3 version compatibility and macOS runner in publish… #5

Workflow file for this run

name: Publish and Create Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
id-token: write
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mymindstorm/setup-emsdk@v14
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- run: npm install -g npm@latest
- run: corepack enable
- run: corepack prepare yarn@4.12.0 --activate
- uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libeigen3-dev
- name: Build and test C++
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure
- run: yarn install --immutable
- run: yarn build
- run: yarn lint
- run: yarn test
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm publish --access public --provenance
python-wheels:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
plat_tag: manylinux_2_17_x86_64
lib_name: libsonare.so
- os: ubuntu-24.04-arm
arch: aarch64
plat_tag: manylinux_2_17_aarch64
lib_name: libsonare.so
- os: macos-latest
arch: arm64
plat_tag: macosx_11_0_arm64
lib_name: libsonare.dylib
# macOS x86_64 omitted: GitHub no longer provides Intel macOS runners
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Eigen3 (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libeigen3-dev
- name: Install Eigen3 (macOS)
if: runner.os == 'macOS'
run: brew install eigen
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Build shared library
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED=ON -DBUILD_TESTING=OFF -DBUILD_CLI=OFF
cmake --build build --config Release -j
- name: Copy shared library
run: cp build/lib/${{ matrix.lib_name }} bindings/python/src/libsonare/
- name: Fix dylib install name (macOS)
if: runner.os == 'macOS'
run: install_name_tool -id @loader_path/libsonare.dylib bindings/python/src/libsonare/libsonare.dylib
- name: Build wheel
run: |
cd bindings/python
pip install wheel hatchling
pip wheel . --no-deps -w dist/
python3 -m wheel tags --platform-tag ${{ matrix.plat_tag }} --remove dist/*.whl
- name: Test wheel
run: |
pip install bindings/python/dist/*.whl pytest
python3 -c "import libsonare; print(f'Version: {libsonare.version()}')"
cd bindings/python && python3 -m pytest tests/ -x -q
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.arch }}
path: bindings/python/dist/*.whl
publish-pypi:
needs: [python-wheels]
if: always() && needs.python-wheels.result == 'success'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/libsonare
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheel-*
path: dist/
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/