JerOrc is building on all platform 🚀 #72
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: libzedmd-python-pybind11-extension | |
| run-name: ${{ github.actor }} is building on all platform 🚀 | |
| on: [workflow_dispatch] | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| version: | |
| name: Detect libzedmd version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.version.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - id: version | |
| working-directory: extern/libzedmd/ | |
| run: | | |
| VERSION_MAJOR=$(grep -Eo "ZEDMD_VERSION_MAJOR\s+[0-9]+" src/ZeDMD.h | grep -Eo "[0-9]+") | |
| VERSION_MINOR=$(grep -Eo "ZEDMD_VERSION_MINOR\s+[0-9]+" src/ZeDMD.h | grep -Eo "[0-9]+") | |
| VERSION_PATCH=$(grep -Eo "ZEDMD_VERSION_PATCH\s+[0-9]+" src/ZeDMD.h | grep -Eo "[0-9]+") | |
| TAG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" | |
| echo "${TAG}" | |
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
| build: | |
| name: Build libzedmd-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.type }} | |
| runs-on: ${{ matrix.os }} | |
| needs: [ version ] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: windows-latest, platform: win, arch: x64, type: Release } | |
| - { os: windows-latest, platform: win, arch: x86, type: Release } | |
| - { os: macos-latest, platform: macos, arch: arm64, type: Release } | |
| - { os: macos-latest, platform: macos, arch: x64, type: Release } | |
| - { os: ubuntu-latest, platform: linux, arch: x64, type: Release } | |
| - { os: ubuntu-24.04-arm, platform: linux, arch: aarch64, type: Release } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - if: (matrix.platform == 'win') | |
| name: Add msbuild to path (win runner) | |
| uses: microsoft/setup-msbuild@v2 | |
| - if: (matrix.platform == 'win') && (matrix.arch == 'x86') | |
| name: Set up Python x86 | |
| uses: actions/setup-python@v5 | |
| with: | |
| architecture: 'x86' | |
| python-version: 3.11.9 | |
| - if: (matrix.platform == 'macos') && (matrix.arch == 'x64') | |
| name: Set up Python x64 | |
| uses: actions/setup-python@v5 | |
| with: | |
| architecture: 'x64' | |
| python-version: 3.11.9 | |
| - if: (matrix.platform == 'macos') | |
| name: Add autoconf and automake (mac runner) | |
| run: | | |
| brew install autoconf automake libtool | |
| - name: Which python | |
| run: which -a python | |
| # - name: Find python | |
| # run: find C:/hostedtoolcache/windows/ -name 'python3*.lib' | |
| - name: Build libzedmd-${{ matrix.platform }}-${{ matrix.arch }} | |
| working-directory: extern/libzedmd/ | |
| run: | | |
| ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh | |
| if [[ "${{ matrix.platform }}" == "win" ]]; then | |
| if [[ "${{ matrix.arch }}" == "x64" ]]; then | |
| cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build | |
| elif [[ "${{ matrix.arch }}" == "x86" ]]; then | |
| cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build | |
| elif [[ "${{ matrix.arch }}" == "arm64" ]]; then | |
| cmake -G "Visual Studio 17 2022" -A ARM64 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build | |
| fi | |
| cmake --build build --config ${{ matrix.type }} | |
| else | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| NUM_PROCS=$(sysctl -n hw.ncpu) | |
| else | |
| NUM_PROCS=$(nproc) | |
| fi | |
| cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build | |
| cmake --build build -- -j${NUM_PROCS} | |
| fi | |
| - if: (matrix.platform == 'win') && (matrix.arch == 'x86') | |
| name: Setting vars for win-x86 | |
| run : | | |
| echo "import sysconfig; print(sysconfig.get_path('include').replace('\\\\','/'))" > temp_script.py | |
| echo "PYTHON_INCLUDE_DIR=$(python temp_script.py)" >> $GITHUB_ENV | |
| echo "import os; import sys; print(os.path.dirname(sys.executable).replace('\\\\','/'))" > temp_script.py | |
| echo "PYTHON_LIBRARY=$(python temp_script.py)/libs/python311.lib" >> $GITHUB_ENV | |
| - if: (matrix.platform == 'win') && (matrix.arch == 'x86') | |
| name: Testing vars for win-x86 | |
| run: | | |
| echo "PYTHON_INCLUDE_DIR=${{ env.PYTHON_INCLUDE_DIR }}" | |
| echo "PYTHON_LIBRARY=${{ env.PYTHON_LIBRARY }}" | |
| - name: Build libzedmd-python-python-extension | |
| working-directory: build/ | |
| run: | | |
| ls ../extern/libzedmd/build | |
| echo '--------------------------------------' | |
| rm -Rf ./* | |
| if [[ "${{ matrix.platform }}" == "win" ]]; then | |
| if [[ "${{ matrix.arch }}" == "x64" ]]; then | |
| cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} .. | |
| elif [[ "${{ matrix.arch }}" == "x86" ]]; then | |
| cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -DPYTHON_INCLUDE_DIR=${{ env.PYTHON_INCLUDE_DIR }} -DPYTHON_LIBRARY=${{ env.PYTHON_LIBRARY }} .. | |
| elif [[ "${{ matrix.arch }}" == "arm64" ]]; then | |
| cmake -G "Visual Studio 17 2022" -A ARM64 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} .. | |
| fi | |
| cmake --build . --config ${{ matrix.type }} | |
| else | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| NUM_PROCS=$(sysctl -n hw.ncpu) | |
| else | |
| NUM_PROCS=$(nproc) | |
| fi | |
| cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} .. | |
| cmake --build . -- -j${NUM_PROCS} | |
| fi | |
| - name: List files in build | |
| working-directory: build/ | |
| run: ls -R | |
| - name: Prepare artifacts | |
| id: artifacts | |
| run: | | |
| mkdir tmp | |
| if [[ "${{ matrix.platform }}" == "win" ]]; then | |
| ARTIFACT_PATH="tmp" | |
| cp extern/libzedmd/build/${{ matrix.type }}/*zedmd*.lib tmp || true | |
| cp extern/libzedmd/build/${{ matrix.type }}/*zedmd*.dll tmp || true | |
| cp extern/libzedmd/build/${{ matrix.type }}/*serialport*.lib tmp || true | |
| cp extern/libzedmd/build/${{ matrix.type }}/*serialport*.dll tmp || true | |
| cp build/*extending*.lib tmp || true | |
| cp build/*extending*.dll tmp || true | |
| else | |
| ARTIFACT_PATH="libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz" | |
| if [[ "${{ matrix.platform }}" == "macos" ]]; then | |
| cp extern/libzedmd/build/*zedmd*.a tmp || true | |
| cp -a extern/libzedmd/build/*serialport*.dylib tmp || true | |
| cp -a extern/libzedmd/build/*zedmd*.dylib tmp || true | |
| cp build/*extending*.a tmp || true | |
| cp -a build/*extending*.dylib tmp || true | |
| elif [[ "${{ matrix.platform }}" == "linux" ]]; then | |
| cp extern/libzedmd/build/*zedmd*.a tmp || true | |
| cp -a extern/libzedmd/build/*serialport*.{so,so.*} tmp || true | |
| cp -a extern/libzedmd/build/*zedmd*.{so,so.*} tmp || true | |
| cp build/*extending*.a tmp || true | |
| cp -a build/*extending*.{so,so.*} tmp || true | |
| fi | |
| cd tmp | |
| tar -czvf ../${ARTIFACT_PATH} * | |
| fi | |
| echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.type }} | |
| path: ${{ steps.artifacts.outputs.artifact_path }} | |
| post-build: | |
| runs-on: macos-latest | |
| needs: [ version, build ] | |
| name: Build libzedmd-macos | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| - name: Unpack artifacts | |
| run: | | |
| cd libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64-Release | |
| tar -xzvf libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64.tar.gz | |
| cd .. | |
| cd libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release | |
| tar -xzvf libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz | |
| - name: Combine macos architectures | |
| run: | | |
| mkdir tmp | |
| find "libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release" -name "*.dylib" | while read -r file; do | |
| if [ -L "$file" ]; then | |
| cp -a "$file" "tmp/" | |
| elif [ -f "$file" ]; then | |
| filename=$(basename "$file") | |
| lipo -create -output "tmp/$filename" \ | |
| "libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release/$filename" \ | |
| "libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64-Release/$filename" | |
| fi | |
| done | |
| - name: Prepare artifacts | |
| run: | | |
| cd tmp | |
| tar -czvf ../libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos.tar.gz * | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-Release | |
| path: libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos.tar.gz | |
| - name: Package | |
| # if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| zip -r libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x64.zip libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x64-Release | |
| zip -r libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x86.zip libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x86-Release | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| # if: startsWith(github.ref, 'refs/tags/v') | |
| with: | |
| draft: true | |
| files: | | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x64.zip | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x86.zip | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64.tar.gz | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos.tar.gz | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-x64/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-x64.tar.gz | |
| libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-aarch64/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz |