CI: manage curl deps for windows #1673
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 | |
| on: [push, pull_request, workflow_dispatch] | |
| env: | |
| BUILD_TYPE: Release | |
| DATA_ROOT: ${{ github.workspace }}/data | |
| DATA_BRANCH: master | |
| GENERATOR_PLATFORM: | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| shared_libs_flag: [ON, OFF] | |
| fail-fast: false # Allow all matrix jobs to run, even if one fails | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: true # Recursively clone submodules | |
| - name: Delete workflow runs | |
| if: startsWith(matrix.os, 'ubuntu') && matrix.shared_libs_flag == 'ON' | |
| uses: Mattraks/delete-workflow-runs@v2.0.6 | |
| - name: ubuntu-dependencies | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| #echo DATA_BRANCH=linux-release >> $GITHUB_ENV | |
| sudo apt update | |
| sudo apt install -y exiftool libpsl-dev libcurl4-openssl-dev | |
| - name: macos-dependencies | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| #echo DATA_BRANCH=osx >> $GITHUB_ENV | |
| brew install exiftool libpsl libssh2 | |
| #perl -MImage::ExifTool -e "" | |
| # Add macOS-specific dependencies if needed | |
| - name: windows-dependencies | |
| if: startsWith(matrix.os, 'windows') | |
| run: | | |
| echo "C:/Users/runneradmin/AppData/Roaming/Python/Python39/Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| echo $env:GITHUB_PATH | |
| $generator= "-DCMAKE_GENERATOR_PLATFORM=x64" | |
| echo "Generator: ${generator}" | |
| echo "GENERATOR_PLATFORM=$generator" >> $env:GITHUB_ENV | |
| C:\vcpkg\vcpkg.exe install libpsl:x64-windows | |
| # Verify installation for shared builds | |
| # if (-Not (Test-Path "C:\vcpkg\installed\x64-windows\bin\libcurl.dll") -And "${{ matrix.shared_libs_flag }}" -eq "ON") { | |
| # Write-Error "libcurl.dll not found in vcpkg installed directory" | |
| # exit 1 | |
| # } | |
| # if (-Not (Test-Path "C:\vcpkg\installed\x64-windows\bin\libpsl.dll") -And "${{ matrix.shared_libs_flag }}" -eq "ON") { | |
| # Write-Error "libpsl.dll not found in vcpkg installed directory" | |
| # exit 1 | |
| # } | |
| echo "CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $env:GITHUB_ENV | |
| # Add vcpkg bin directory to PATH for runtime DLL discovery | |
| echo "C:\vcpkg\installed\x64-windows\bin" >> $env:GITHUB_PATH | |
| - name: dependencies | |
| run: | | |
| cmake -E make_directory ${{ github.workspace }}/build | |
| git clone --depth=1 --branch=${{ env.DATA_BRANCH }} https://github.com/GrokImageCompression/grok-test-data.git ${{ env.DATA_ROOT }} | |
| - name: configure cmake | |
| # Use a bash shell so we can use the same syntax for environment variable | |
| # access regardless of the host operating system | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/build | |
| # Note the current convention is to use the -S and -B options here to specify source | |
| # and build directories, but this is only available with CMake 3.13 and higher. | |
| # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 | |
| run: | | |
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=${{ matrix.shared_libs_flag }} -DBUILD_TESTING:BOOL=ON -DGRK_DATA_ROOT=$DATA_ROOT -DGRK_ENABLE_LIBCURL=OFF $GENERATOR_PLATFORM | |
| else | |
| cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=${{ matrix.shared_libs_flag }} -DBUILD_TESTING:BOOL=ON -DGRK_DATA_ROOT=$DATA_ROOT -DGRK_ENABLE_LIBCURL=ON $GENERATOR_PLATFORM | |
| fi | |
| - name: build | |
| working-directory: ${{ github.workspace }}/build | |
| shell: bash | |
| # Execute the build. You can specify a specific target with "--target <NAME>" | |
| run: cmake --build . --config $BUILD_TYPE | |
| - name: copy-windows-dlls | |
| if: startsWith(matrix.os, 'windows') && matrix.shared_libs_flag == 'ON' | |
| working-directory: ${{ github.workspace }}/build | |
| shell: cmd | |
| run: | | |
| REM Copy libcurl.dll and its dependencies to the output directory for shared builds | |
| # if exist "C:\vcpkg\installed\x64-windows\bin\libcurl.dll" ( | |
| # copy "C:\vcpkg\installed\x64-windows\bin\libcurl.dll" "bin\" | |
| # ) else ( | |
| # echo libcurl.dll not found, skipping copy | |
| # ) | |
| if exist "C:\vcpkg\installed\x64-windows\bin\libpsl.dll" ( | |
| copy "C:\vcpkg\installed\x64-windows\bin\libpsl.dll" "bin\" | |
| ) else ( | |
| echo libpsl.dll not found, skipping copy | |
| ) | |
| REM Copy other common dependencies (adjust based on vcpkg list if needed) | |
| if exist "C:\vcpkg\installed\x64-windows\bin\libidn2-0.dll" ( | |
| copy "C:\vcpkg\installed\x64-windows\bin\libidn2-0.dll" "bin\" | |
| ) | |
| if exist "C:\vcpkg\installed\x64-windows\bin\libunistring-2.dll" ( | |
| copy "C:\vcpkg\installed\x64-windows\bin\libunistring-2.dll" "bin\" | |
| ) | |
| if exist "C:\vcpkg\installed\x64-windows\bin\zlib1.dll" ( | |
| copy "C:\vcpkg\installed\x64-windows\bin\zlib1.dll" "bin\" | |
| ) | |
| if exist "C:\vcpkg\installed\x64-windows\bin\libssl-3-x64.dll" ( | |
| copy "C:\vcpkg\installed\x64-windows\bin\libssl-3-x64.dll" "bin\" | |
| ) | |
| if exist "C:\vcpkg\installed\x64-windows\bin\libcrypto-3-x64.dll" ( | |
| copy "C:\vcpkg\installed\x64-windows\bin\libcrypto-3-x64.dll" "bin\" | |
| ) | |
| - name: test | |
| working-directory: ${{ github.workspace }}/build | |
| shell: bash | |
| continue-on-error: true # Allow test failures, but no other failures | |
| run: | | |
| ctest --output-on-failure -C $BUILD_TYPE --output-junit test-results-${{ matrix.os }}-${{ matrix.shared_libs_flag }}.xml | |
| if [ $? -eq 0 ]; then | |
| echo "Tests passed" > test-status.txt | |
| else | |
| echo "Tests had failures (ignored due to continue-on-error)" > test-status.txt | |
| fi | |
| - name: Upload test results | |
| if: always() # Upload even if tests fail | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.shared_libs_flag }} | |
| path: | | |
| ${{ github.workspace }}/build/test-results-${{ matrix.os }}-${{ matrix.shared_libs_flag }}.xml | |
| ${{ github.workspace }}/build/test-status.txt | |
| - name: package | |
| if: ${{ matrix.shared_libs_flag == 'ON' }} | |
| working-directory: ${{ github.workspace }}/build | |
| shell: bash | |
| run: | | |
| cmake -Wno-dev -D CPACK_GENERATOR:STRING=ZIP -D CPACK_PACKAGE_FILE_NAME:STRING=grok-${{ matrix.os }} . | |
| cmake --build . --config $BUILD_TYPE --target package | |
| 7z x grok-${{ matrix.os }}.zip | |
| - name: publish | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grok-${{ matrix.os }} | |
| path: ${{ github.workspace }}/build/grok-${{ matrix.os }} | |
| - name: Upload binaries to release | |
| uses: softprops/action-gh-release@v1 | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| with: | |
| files: build/grok-${{ matrix.os }}.zip |