Add CounterPosition to move the counter on a Street
#304
Workflow file for this run
This file contains hidden or 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: "CD: PyPI package" | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| BUILD_TYPE: Release | |
| jobs: | |
| check-version: | |
| name: Check if version exists on PyPI/TestPyPI | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_build: ${{ steps.check.outputs.should_build }} | |
| version: ${{ steps.extract.outputs.version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from dsf.hpp | |
| id: extract | |
| run: | | |
| VERSION_MAJOR=$(grep -oP 'DSF_VERSION_MAJOR = \K\d+' src/dsf/dsf.hpp) | |
| VERSION_MINOR=$(grep -oP 'DSF_VERSION_MINOR = \K\d+' src/dsf/dsf.hpp) | |
| VERSION_PATCH=$(grep -oP 'DSF_VERSION_PATCH = \K\d+' src/dsf/dsf.hpp) | |
| VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Extracted version: ${VERSION}" | |
| - name: Check if version exists on PyPI or TestPyPI | |
| id: check | |
| run: | | |
| VERSION="${{ steps.extract.outputs.version }}" | |
| # Determine which PyPI to check based on event type | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| PYPI_URL="https://test.pypi.org/pypi/dsf-mobility/${VERSION}/json" | |
| PYPI_NAME="TestPyPI" | |
| else | |
| PYPI_URL="https://pypi.org/pypi/dsf-mobility/${VERSION}/json" | |
| PYPI_NAME="PyPI" | |
| fi | |
| echo "Checking if dsf-mobility version ${VERSION} exists on ${PYPI_NAME}..." | |
| # Check PyPI/TestPyPI API for the specific version | |
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${PYPI_URL}") | |
| if [ "$HTTP_STATUS" = "200" ]; then | |
| echo "Version ${VERSION} already exists on ${PYPI_NAME}" | |
| echo "should_build=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version ${VERSION} does not exist on ${PYPI_NAME} (HTTP ${HTTP_STATUS})" | |
| echo "should_build=true" >> $GITHUB_OUTPUT | |
| fi | |
| build-wheels-linux: | |
| name: Build wheels on Linux (Python ${{ matrix.python-version }}) | |
| needs: [check-version] | |
| runs-on: ubuntu-latest | |
| if: needs.check-version.outputs.should_build == 'true' | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.12'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y cmake build-essential doxygen libtbb-dev | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build wheel setuptools pybind11-stubgen auditwheel | |
| - name: Build wheel | |
| env: | |
| CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF" | |
| run: | | |
| rm -rf dist wheelhouse | |
| python -m build --wheel | |
| - name: Repair wheel (auditwheel) | |
| run: | | |
| mkdir -p wheelhouse | |
| auditwheel repair dist/*.whl -w wheelhouse | |
| - name: Test wheel installation | |
| run: | | |
| python -m pip install wheelhouse/*.whl | |
| python -c "import dsf; print('DSF wheel installation successful')" | |
| - name: Upload wheels as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-linux-${{ matrix.python-version }} | |
| path: wheelhouse/*.whl | |
| build-wheels-macos: | |
| name: Build wheels on macOS (Python ${{ matrix.python-version }}) | |
| needs: [check-version] | |
| runs-on: macos-latest | |
| if: needs.check-version.outputs.should_build == 'true' | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.12'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies | |
| run: | | |
| brew install cmake doxygen tbb | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build wheel setuptools pybind11-stubgen delocate | |
| - name: Set macOS environment variables | |
| run: | | |
| echo "ARCHFLAGS=-arch $(uname -m)" >> $GITHUB_ENV | |
| echo "_PYTHON_HOST_PLATFORM=macosx-$(sw_vers -productVersion | cut -d. -f1)-$(uname -m)" >> $GITHUB_ENV | |
| - name: Build wheel | |
| env: | |
| CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF" | |
| run: python -m build --wheel | |
| - name: Repair wheel (bundle libraries) | |
| run: | | |
| mkdir -p wheelhouse | |
| delocate-wheel -w wheelhouse -v --require-archs $(uname -m) dist/*.whl | |
| - name: Upload wheels as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-macos-${{ matrix.python-version }} | |
| path: wheelhouse/*.whl | |
| build-wheels-windows: | |
| name: Build wheels on Windows (Python ${{ matrix.python-version }}) | |
| needs: [check-version] | |
| runs-on: windows-latest | |
| if: needs.check-version.outputs.should_build == 'true' | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.12'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies | |
| run: | | |
| choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' | |
| choco install doxygen.install | |
| git clone https://github.com/microsoft/vcpkg.git vcpkg | |
| cd vcpkg | |
| .\bootstrap-vcpkg.bat | |
| .\vcpkg install tbb:x64-windows | |
| echo "CMAKE_TOOLCHAIN_FILE=$env:GITHUB_WORKSPACE\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $env:GITHUB_ENV | |
| echo "VCPKG_TARGET_TRIPLET=x64-windows" >> $env:GITHUB_ENV | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build wheel setuptools pybind11-stubgen | |
| - name: Build wheel | |
| env: | |
| CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF" | |
| run: python -m build --wheel | |
| - name: Upload wheels as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-windows-${{ matrix.python-version }} | |
| path: dist/*.whl | |
| build-sdist: | |
| name: Build source distribution | |
| needs: [check-version] | |
| runs-on: ubuntu-latest | |
| if: needs.check-version.outputs.should_build == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.12" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y cmake build-essential doxygen libtbb-dev | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build | |
| - name: Build source distribution | |
| run: python -m build --sdist | |
| - name: Upload sdist as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [check-version, build-wheels-linux, build-wheels-macos, build-wheels-windows, build-sdist] | |
| runs-on: ubuntu-latest | |
| if: needs.check-version.outputs.should_build == 'true' | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist-artifacts | |
| - name: Collect all distributions | |
| run: | | |
| mkdir -p dist | |
| find dist-artifacts -name '*.whl' -exec cp {} dist/ \; | |
| find dist-artifacts -name '*.tar.gz' -exec cp {} dist/ \; | |
| echo "Contents of dist/:" | |
| ls -la dist/ | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.12" | |
| - name: Install twine | |
| run: python -m pip install twine | |
| - name: Publish to TestPyPI (on PR) | |
| if: github.event_name == 'pull_request' | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI }} | |
| run: | | |
| python -m twine upload --repository testpypi dist/* --verbose | |
| - name: Publish to PyPI (on push to main) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI }} | |
| run: | | |
| python -m twine upload dist/* --verbose |