Rework next streetid computation #221
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 libfmt-dev libspdlog-dev libsimdjson-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 | |
| 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 tbb spdlog simdjson doxygen | |
| - 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 "CPLUS_INCLUDE_PATH=$(brew --prefix tbb)/include:$(brew --prefix fmt)/include:$(brew --prefix spdlog)/include:$(brew --prefix simdjson)/include" >> $GITHUB_ENV | |
| echo "LIBRARY_PATH=$(brew --prefix tbb)/lib:$(brew --prefix fmt)/lib:$(brew --prefix spdlog)/lib:$(brew --prefix simdjson)/lib" >> $GITHUB_ENV | |
| echo "CMAKE_PREFIX_PATH=$(brew --prefix tbb);$(brew --prefix fmt);$(brew --prefix spdlog);$(brew --prefix simdjson)" >> $GITHUB_ENV | |
| 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 | |
| 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-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 libtbb-dev libspdlog-dev libsimdjson-dev doxygen | |
| - 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-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 |