| 1 | name: Build Platform Wheels and Conda Packages |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [ main, master ] |
| 6 | paths: |
| 7 | - 'OtherLanguages/Python/**' |
| 8 | - 'src/**' |
| 9 | - 'build/conda/**' |
| 10 | - '.github/workflows/build_wheels.yml' |
| 11 | tags: |
| 12 | - 'v*' |
| 13 | pull_request: |
| 14 | paths: |
| 15 | - 'OtherLanguages/Python/**' |
| 16 | - 'src/**' |
| 17 | - 'build/conda/**' |
| 18 | - '.github/workflows/build_wheels.yml' |
| 19 | workflow_dispatch: |
| 20 | |
| 21 | permissions: |
| 22 | contents: read |
| 23 | |
| 24 | jobs: |
| 25 | build_wheels: |
| 26 | name: Build Wheels on ${{ matrix.os }} |
| 27 | runs-on: ${{ matrix.os }} |
| 28 | strategy: |
| 29 | matrix: |
| 30 | os: [ubuntu-latest, windows-latest, macos-latest] |
| 31 | |
| 32 | steps: |
| 33 | - name: Checkout Code |
| 34 | uses: actions/checkout@v4 |
| 35 | |
| 36 | - name: Build C++ Binaries (Linux Container Compatibility) |
| 37 | if: matrix.os == 'ubuntu-latest' |
| 38 | uses: addnab/docker-run-action@v3 |
| 39 | with: |
| 40 | image: rockylinux:8 |
| 41 | options: -v ${{ github.workspace }}:/workspace |
| 42 | run: | |
| 43 | dnf install -y gcc-c++ cmake make |
| 44 | cd /workspace |
| 45 | mkdir -p cmake_build |
| 46 | cd cmake_build |
| 47 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH="\$ORIGIN/../../..\$ORIGIN/../lib" |
| 48 | cmake --build . --config Release |
| 49 | |
| 50 | - name: Build C++ Binaries (Windows & macOS Native) |
| 51 | if: matrix.os != 'ubuntu-latest' |
| 52 | shell: bash |
| 53 | env: |
| 54 | MACOSX_DEPLOYMENT_TARGET: '11.0' |
| 55 | run: | |
| 56 | mkdir cmake_build |
| 57 | cd cmake_build |
| 58 | if [ "${{ matrix.os }}" = "macos-latest" ]; then |
| 59 | cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" |
| 60 | else |
| 61 | cmake .. -DCMAKE_BUILD_TYPE=Release |
| 62 | fi |
| 63 | cmake --build . --config Release |
| 64 | |
| 65 | - name: Stage Binaries for setup.py |
| 66 | shell: bash |
| 67 | run: | |
| 68 | mkdir -p bin/Linux bin/windows bin/MacOS |
| 69 | |
| 70 | if [ "${{ matrix.os }}" = "windows-latest" ]; then |
| 71 | cp cmake_build/Release/Lerc.dll bin/windows/ || cp cmake_build/Lerc.dll bin/windows/ || echo "DLL not found" |
| 72 | cp cmake_build/Release/Lerc.lib bin/windows/ || cp cmake_build/Lerc.lib bin/windows/ || echo "LIB not found" |
| 73 | elif [ "${{ matrix.os }}" = "macos-latest" ]; then |
| 74 | cp cmake_build/libLerc.dylib bin/MacOS/ || cp cmake_build/Release/libLerc.dylib bin/MacOS/ || echo "DYLIB not found" |
| 75 | else |
| 76 | cp cmake_build/libLerc.so.4 bin/Linux/ || cp cmake_build/Release/libLerc.so.4 bin/Linux/ || \ |
| 77 | cp cmake_build/libLerc.so bin/Linux/libLerc.so.4 || \ |
| 78 | cp cmake_build/Release/libLerc.so bin/Linux/libLerc.so.4 || echo "libLerc.so.4 not found" |
| 79 | fi |
| 80 | |
| 81 | - name: Set up Python |
| 82 | uses: actions/setup-python@v5 |
| 83 | with: |
| 84 | python-version: '3.11' |
| 85 | |
| 86 | - name: Build Wheel |
| 87 | env: |
| 88 | MACOSX_DEPLOYMENT_TARGET: '11.0' |
| 89 | run: | |
| 90 | python -m pip install --upgrade pip setuptools wheel build |
| 91 | cd OtherLanguages/Python |
| 92 | python setup.py build |
| 93 | python -m build --wheel |
| 94 | |
| 95 | - name: Standardize Wheel Platform Labels |
| 96 | shell: bash |
| 97 | run: | |
| 98 | cd OtherLanguages/Python/dist/ |
| 99 | if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then |
| 100 | for f in *linux_x86_64.whl; do [ -e "$f" ] && mv "$f" "${f/linux_x86_64/manylinux_2_28_x86_64}"; done |
| 101 | fi |
| 102 | |
| 103 | - name: Upload Platform Wheel Artifacts |
| 104 | uses: actions/upload-artifact@v4 |
| 105 | with: |
| 106 | name: pylerc-wheels-${{ matrix.os }} |
| 107 | path: OtherLanguages/Python/dist/*.whl |
| 108 | |
| 109 | - name: Upload Binary Snippets for Conda |
| 110 | uses: actions/upload-artifact@v4 |
| 111 | with: |
| 112 | name: compiled-binaries-${{ matrix.os }} |
| 113 | path: bin/ |
| 114 | |
| 115 | build_conda: |
| 116 | name: Assemble Noarch Conda Package |
| 117 | needs: build_wheels |
| 118 | runs-on: ubuntu-latest |
| 119 | steps: |
| 120 | - name: Checkout Code |
| 121 | uses: actions/checkout@v4 |
| 122 | |
| 123 | - name: Download Windows Binaries |
| 124 | uses: actions/download-artifact@v4 |
| 125 | with: |
| 126 | name: compiled-binaries-windows-latest |
| 127 | path: bin/ |
| 128 | |
| 129 | - name: Download MacOS Binaries |
| 130 | uses: actions/download-artifact@v4 |
| 131 | with: |
| 132 | name: compiled-binaries-macos-latest |
| 133 | path: bin/ |
| 134 | |
| 135 | - name: Download Linux Binaries |
| 136 | uses: actions/download-artifact@v4 |
| 137 | with: |
| 138 | name: compiled-binaries-ubuntu-latest |
| 139 | path: bin/ |
| 140 | |
| 141 | - name: Setup Miniconda Environment |
| 142 | uses: conda-incubator/setup-miniconda@v4 |
| 143 | with: |
| 144 | auto-update-conda: true |
| 145 | auto-activate: true |
| 146 | activate-environment: "" |
| 147 | |
| 148 | - name: Install Conda Build Tooling |
| 149 | shell: bash -el {0} |
| 150 | run: conda install -y python=3.11 conda-build |
| 151 | |
| 152 | - name: Build Noarch Conda Distribution |
| 153 | shell: bash -el {0} |
| 154 | run: | |
| 155 | cd OtherLanguages/Python |
| 156 | python setup.py build |
| 157 | cd ../.. |
| 158 | mkdir -p conda-out |
| 159 | conda build build/conda/lerc/ --output-folder conda-out/ |
| 160 | |
| 161 | - name: Upload Conda Distribution Artifacts |
| 162 | uses: actions/upload-artifact@v4 |
| 163 | with: |
| 164 | name: pylerc-conda-package |
| 165 | path: conda-out/noarch/*.conda |
| 166 | |
| 167 |