Skip to content

ci: only build sdist #80

ci: only build sdist

ci: only build sdist #80

Workflow file for this run

name: CI
on:
push:
branches: [main]
paths-ignore:
- 'README.md'
pull_request:
branches: [main]
paths-ignore:
- 'README.md'
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake make g++ build-essential libboost-all-dev
- name: Configure CMake
run: cmake -S . -B build -DBUILD_BINDINGS=OFF -DBUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tests
run: |
cd build
ctest -V
build:
needs: test
runs-on: ${{ matrix.os }}
outputs:
new_version: ${{ steps.bump_version.outputs.new_version }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.11] # Choose one version for the build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
if [ $RUNNER_OS == 'Linux' ]; then
sudo apt-get update
sudo apt-get install -y cmake make g++ build-essential libboost-all-dev
fi
if [ $RUNNER_OS == 'macOS' ]; then
brew install cmake boost
fi
pip3 install setuptools wheel twine scikit-build pybind11
- name: Bump version
id: bump_version
run: |
./bump_version.sh
- name: Commit and tag version
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git add setup.py
git commit -m "Bump version to ${{ steps.new_version.new_version.new_version }}"
git tag "v${{ steps.bump_version.outputs.new_version }}"
git push origin main --tags || true
- name: Build Python package
run: python3 setup.py sdist
- name: Upload build artifacts (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: dist-linux-${{ steps.bump_version.outputs.new_version }}
path: dist
- name: Upload build artifacts (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: dist-macos-${{ steps.bump_version.outputs.new_version }}
path: dist
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check version bump
run: |
if [ -z "${{ needs.build.outputs.new_version }}" ]; then
echo "No new version found. Exiting."
exit 1
fi
- name: Download build artifacts (MacOS)
uses: actions/download-artifact@v4
with:
name: dist-macos-${{ needs.build.outputs.new_version }}
path: dist
- name: Download build artifacts (Linux)
uses: actions/download-artifact@v4
with:
name: dist-linux-${{ needs.build.outputs.new_version }}
path: dist
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: 'dist/*'
token: ${{ secrets.PAT }}
tag: ${{ needs.build.outputs.new_version }}
name: ${{ needs.build.outputs.new_version }}
body: "Release generated by GitHub Actions"
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
package: dist/*