ci: make it accessable in macos #59
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
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 | |
- name: Build | |
run: cmake --build build | |
- name: Run tests | |
run: | | |
cd build | |
ctest -V | |
build: | |
needs: test | |
runs-on: ${{ matrix.os }} | |
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: 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.bump_version.outputs.new_version }}" | |
git tag "v${{ steps.bump_version.outputs.new_version }}" | |
git push origin main --tags | |
- 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 | |
- name: Configure CMake | |
run: cmake -S . -B build -DBUILD_BINDINGS=OFF | |
- name: Build | |
run: cmake --build build | |
- name: Build Python package | |
run: python3 setup.py sdist bdist_wheel | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-${{ matrix.os }}-${{ 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: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist-ubuntu-${{ steps.bump_version.outputs.new_version }}, dist-macos-${{ steps.bump_version.outputs.new_version }} | |
path: dist | |
- name: Create GitHub release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: 'dist/*' | |
token: ${{ secrets.PAT }} | |
tag: ${{ steps.bump_version.outputs.new_version }} | |
name: ${{ steps.bump_version.outputs.version }} | |
body: "Release generated by GitHub Actions" | |
pypi-publish: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools twine | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
package: dist/* |