Skip to content

ci: fix new_version output bug #84

ci: fix new_version output bug

ci: fix new_version output bug #84

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_and_build:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump_version.outputs.new_version }}
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
pip3 install setuptools wheel twine scikit-build pybind11 pytest
- name: Configure CMake
run: cmake -S . -B build -DBUILD_BINDINGS=OFF -DBUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tests (C++)
run: |
cd build
ctest -V
- name: Run tests (Python)
run: |
pip3 install .
pytest
- 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 || true
- name: Build Python package
run: python3 setup.py sdist
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ steps.bump_version.outputs.new_version }}
path: dist
release:
needs: test_and_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.test_and_build.outputs.new_version }}" ]; then
echo "No new version found. Exiting."
exit 1
fi
- name: Download build artifacts (Linux)
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.test_and_build.outputs.new_version }}
path: dist
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: 'dist/*'
token: ${{ secrets.PAT }}
tag: ${{ needs.test_and_build.outputs.new_version }}
name: ${{ needs.test_and_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/*