Build onnxruntime FreeBSD Wheel #17
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: Build onnxruntime FreeBSD Wheel | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| onnxruntime_version: | |
| description: 'onnxruntime version to build' | |
| required: true | |
| default: '1.23.2' | |
| python_version: | |
| description: 'Python version' | |
| required: true | |
| default: '3.11' | |
| type: choice | |
| options: | |
| - '3.11' | |
| - '3.12' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build onnxruntime wheel on FreeBSD | |
| uses: vmactions/freebsd-vm@v1 | |
| with: | |
| release: '15.0' | |
| usesh: true | |
| copyback: true | |
| prepare: | | |
| pkg install -y cmake ninja gmake git patch \ | |
| python${{ inputs.python_version == '3.11' && '311' || '312' }} \ | |
| py${{ inputs.python_version == '3.11' && '311' || '312' }}-pip \ | |
| py${{ inputs.python_version == '3.11' && '311' || '312' }}-setuptools \ | |
| py${{ inputs.python_version == '3.11' && '311' || '312' }}-wheel \ | |
| py${{ inputs.python_version == '3.11' && '311' || '312' }}-numpy \ | |
| py${{ inputs.python_version == '3.11' && '311' || '312' }}-pybind11 | |
| # Override BSD patch with GNU patch (onnxruntime uses --binary flag) | |
| mv /usr/bin/patch /usr/bin/patch.bsd | |
| ln -sf /usr/local/bin/gpatch /usr/bin/patch | |
| which patch && patch --version | head -1 | |
| run: | | |
| set -ex | |
| PYVER=${{ inputs.python_version == '3.11' && '311' || '312' }} | |
| PYTHON=python${PYVER%??}.${PYVER#?} | |
| VERSION=${{ inputs.onnxruntime_version }} | |
| # Clone onnxruntime | |
| git clone --depth 1 --branch v${VERSION} --recursive \ | |
| https://github.com/microsoft/onnxruntime.git | |
| cd onnxruntime | |
| # Apply FreeBSD patch (from checked-out repo) | |
| patch -p1 < ../patches/onnxruntime-freebsd.patch | |
| # Build with wheel generation | |
| # Extra include path needed for logging.h on FreeBSD | |
| export CXXFLAGS="-I$(pwd)/include/onnxruntime/core/common/logging" | |
| CC=clang CXX=clang++ ${PYTHON} ./tools/ci_build/build.py \ | |
| --build_dir ./build/FreeBSD \ | |
| --config Release \ | |
| --enable_pybind \ | |
| --build_wheel \ | |
| --skip_tests \ | |
| --parallel \ | |
| --compile_no_warning_as_error \ | |
| --allow_running_as_root | |
| # Copy wheel to workspace for upload | |
| mkdir -p ../dist | |
| cp build/FreeBSD/Release/dist/onnxruntime-*.whl ../dist/ | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: onnxruntime-freebsd-py${{ inputs.python_version }} | |
| path: dist/*.whl | |
| if-no-files-found: error | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download wheel | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: onnxruntime-freebsd-py${{ inputs.python_version }} | |
| path: dist | |
| - name: Create or Update Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ONNX_VERSION: ${{ inputs.onnxruntime_version }} | |
| PY_VERSION: ${{ inputs.python_version }} | |
| run: | | |
| WHEEL=$(ls dist/*.whl | head -1) | |
| TAG="onnxruntime-${ONNX_VERSION}" | |
| # Create release if it doesn't exist, otherwise upload to existing | |
| if gh release view "${TAG}" >/dev/null 2>&1; then | |
| gh release upload "${TAG}" "${WHEEL}" --clobber | |
| else | |
| gh release create "${TAG}" \ | |
| "${WHEEL}" \ | |
| --title "onnxruntime ${ONNX_VERSION} FreeBSD wheel" \ | |
| --notes "Pre-built onnxruntime ${ONNX_VERSION} wheel for FreeBSD 15.0 / Python ${PY_VERSION} (amd64, CPU only)" | |
| fi |