vcpkg.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. ---
  2. name: 🎁 Package with vcpkg
  3. on:
  4. push:
  5. branches:
  6. - master
  7. - release-**
  8. pull_request:
  9. release:
  10. types: ['published', 'released']
  11. jobs:
  12. build:
  13. runs-on: ${{ matrix.os }}
  14. strategy:
  15. fail-fast: false
  16. matrix:
  17. include:
  18. - triplet: 'x64-windows'
  19. os: 'windows-2019'
  20. - triplet: 'x64-linux'
  21. os: 'ubuntu-20.04'
  22. - triplet: 'x64-osx'
  23. os: 'macos-10.15'
  24. steps:
  25. # Avoid that we run out of disk space
  26. # - name: Free additional space
  27. # uses: easimon/maximize-build-space@master
  28. # if: ${{ matrix.triplet == 'x64-linux' }}
  29. # with:
  30. # remove-haskell: true # 9G
  31. # remove-android: true # 18G
  32. # remove-dotnet: true # 30G
  33. - name: 🐣 Checkout
  34. uses: actions/checkout@v2
  35. with:
  36. submodules: recursive
  37. - name: 🌾 Prepare vars
  38. id: vars
  39. shell: bash
  40. run: |
  41. ./scripts/ci/env_gh.sh
  42. case ${{ matrix.triplet }} in
  43. x64-windows)
  44. BUILD_ROOT="C:"
  45. echo "::set-output name=MONO::"
  46. echo "::set-output name=PATHCONVERT::cygpath -u"
  47. echo "::set-output name=EXCLUDE_TESTS::(smoke_test)"
  48. ;;
  49. x64-linux)
  50. BUILD_ROOT="/home/runner"
  51. echo "::set-output name=MONO::mono"
  52. echo "::set-output name=OVERLAY::vcpkg/overlay_system_qt"
  53. echo "::set-output name=PATHCONVERT::echo"
  54. echo "::set-output name=INSTALL_QT::true"
  55. echo "::set-output name=QT_TARGET::desktop"
  56. echo "::set-output name=QT_ARCH::"
  57. ;;
  58. x64-osx)
  59. BUILD_ROOT="/Users/runner"
  60. echo "::set-output name=MONO::mono"
  61. echo "::set-output name=OVERLAY::vcpkg/overlay_system_qt"
  62. echo "::set-output name=PATHCONVERT::echo"
  63. echo "::set-output name=INSTALL_QT::true"
  64. echo "::set-output name=QT_TARGET::desktop"
  65. echo "::set-output name=QT_ARCH::"
  66. ;;
  67. esac
  68. echo "::set-output name=VCPKG_ROOT::${BUILD_ROOT}/src"
  69. echo "::set-output name=BUILD_TYPE::Release"
  70. echo "::set-output name=BUILD_ROOT::${BUILD_ROOT}"
  71. echo "VCPKG_ROOT=${BUILD_ROOT}/src" >> $GITHUB_ENV
  72. echo "CMAKE_BUILD_DIR=${BUILD_ROOT}/builddir" >> $GITHUB_ENV
  73. echo "VCPKG_DEFAULT_BINARY_CACHE=${BUILD_ROOT}/vcpkg_cache" >> $GITHUB_ENV
  74. - name: 🐩 Install CMake and Ninja
  75. uses: lukka/get-cmake@latest
  76. - name: 📪 Clone vcpkg
  77. shell: bash
  78. run: |
  79. VCPKG_SHA=$(head -1 .git/modules/vcpkg/HEAD)
  80. mkdir -p "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}"
  81. mkdir -p "${{ steps.vars.outputs.VCPKG_ROOT }}"
  82. cd "${{ steps.vars.outputs.VCPKG_ROOT }}"
  83. git init
  84. git remote add origin https://github.com/microsoft/vcpkg.git
  85. git fetch --depth 1 origin $VCPKG_SHA
  86. git checkout FETCH_HEAD
  87. - name: 📫 Cache vcpkg
  88. id: cache-vcpkg-tool
  89. uses: pat-s/always-upload-cache@v2.1.5
  90. with:
  91. path: |
  92. ${{ steps.vars.outputs.VCPKG_ROOT }}/vcpkg
  93. ${{ steps.vars.outputs.VCPKG_ROOT }}/vcpkg.exe
  94. key: ${{ runner.os }}-${{ hashFiles('.git/modules/vcpkg/HEAD') }}-x
  95. - name: 📬 Bootstrap vcpkg
  96. if: steps.cache-vcpkg-tool.outputs.cache-hit != 'true'
  97. shell: bash
  98. working-directory: ${{ steps.vars.outputs.VCPKG_ROOT }}
  99. run: |
  100. if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null ; then
  101. ./bootstrap-vcpkg.bat
  102. else
  103. ./bootstrap-vcpkg.sh
  104. fi
  105. - name: 🔐 Setup NuGet Credentials
  106. shell: bash
  107. run: |
  108. ${{ steps.vars.outputs.VCPKG_ROOT }}/vcpkg fetch nuget
  109. ${{ steps.vars.outputs.MONO }} $(${{ steps.vars.outputs.VCPKG_ROOT }}/vcpkg fetch nuget | tail -n 1) \
  110. sources add \
  111. -source "https://nuget.pkg.github.com/opengisch/index.json" \
  112. -storepasswordincleartext \
  113. -name "GitHub" \
  114. -username "opengisch" \
  115. -password "${{ secrets.GITHUB_TOKEN }}"
  116. ${{ steps.vars.outputs.MONO }} $(${{ steps.vars.outputs.VCPKG_ROOT }}/vcpkg fetch nuget | tail -n 1) \
  117. setapikey ${{ secrets.GITHUB_TOKEN }} -src "https://nuget.pkg.github.com/opengisch/index.json"
  118. - name: 🧽 Developer Command Prompt for Microsoft Visual C++
  119. uses: ilammy/msvc-dev-cmd@v1
  120. if: ${{ matrix.os == 'windows-2019' }}
  121. - name: 🔥 Free additional space
  122. if: ${{ matrix.triplet == 'x64-linux' }}
  123. run: |
  124. df -h
  125. sudo rm -rf /usr/share/dotnet/sdk
  126. sudo rm -rf /usr/share/rust
  127. sudo rm -rf /usr/share/swift
  128. sudo rm -rf /usr/local/lib/android
  129. sudo apt remove llvm-* ghc-* google-chrome-* dotnet-sdk-* azure-cli google-cloud-sdk google-chrome-stable firefox
  130. dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
  131. du -a /usr/share | sort -n -r | head -n 10
  132. du -a /usr/local/share | sort -n -r | head -n 10
  133. df -h
  134. sudo apt clean
  135. df -h
  136. - name: 💐 Install Qt
  137. if: ${{ steps.vars.outputs.INSTALL_QT }}
  138. uses: jurplel/install-qt-action@v2
  139. with:
  140. version: 5.15.2
  141. modules: 'qtcharts'
  142. target: ${{ steps.vars.outputs.QT_TARGET }}
  143. arch: ${{ steps.vars.outputs.QT_ARCH }}
  144. - name: 🐧 Prepare linux build env
  145. if: ${{ matrix.triplet == 'x64-linux' }}
  146. run: |
  147. sudo apt-get update
  148. sudo apt-get install -y gperf autopoint '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
  149. sudo apt-get remove -y libopenexr-dev # Avoid gdal picking this system lib up
  150. # Required to run unit tests on linux
  151. echo "QT_QPA_PLATFORM=offscreen" >> $GITHUB_ENV
  152. echo "TESTWRAPPER=xvfb-run" >> $GITHUB_ENV
  153. echo "EXTRA_CMAKE_ARGS=-GNinja -DCMAKE_INSTALL_PREFIX=/usr -DLINUXDEPLOY_EXECUTABLE=${{ steps.vars.outputs.BUILD_ROOT }}/linuxdeploy-x86_64.AppImage" >> $GITHUB_ENV
  154. - name: Install linuxdeploy
  155. if: ${{ matrix.triplet == 'x64-linux' }}
  156. uses: miurahr/install-linuxdeploy-action@v1
  157. with:
  158. dir: ${{ steps.vars.outputs.BUILD_ROOT }}
  159. plugins: qt appimage
  160. # transifex-client is not compatible with py >= 3.10
  161. # temporary band aid
  162. - uses: actions/setup-python@v2
  163. with:
  164. python-version: '3.9'
  165. - name: 🌍 Pull Translations
  166. shell: bash
  167. env:
  168. TX_TOKEN: ${{ secrets.TX_TOKEN }}
  169. run: |
  170. if [[ -z "${TX_TOKEN}" ]]; then
  171. echo "TX_TOKEN not set, skip tx pull"
  172. else
  173. pip install transifex-client>=0.14.3
  174. ./scripts/ci/pull_translations.sh
  175. fi
  176. - name: Prepare osx build env
  177. if: ${{ matrix.os == 'macos-10.15' }}
  178. run: |
  179. brew install automake bison flex
  180. echo $(brew --prefix bison)/bin >> $GITHUB_PATH
  181. echo $(brew --prefix flex)/bin >> $GITHUB_PATH
  182. echo "EXTRA_CMAKE_ARGS=-GXcode -DUSE_MAC_BUNDLING=OFF" >> $GITHUB_ENV
  183. sudo xcode-select -s /Applications/Xcode_12.app/Contents/Developer
  184. - name: 🌱 Install dependencies and generate project files
  185. shell: bash
  186. env:
  187. WORKSPACE: ${{ github.workspace }}
  188. VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
  189. run: |
  190. # Convert paths to bash compatible ones. Thanks to whoever decided to use drive letters and backslashes.
  191. CMAKE_BUILD_DIR=$( ${{ steps.vars.outputs.PATHCONVERT }} "${CMAKE_BUILD_DIR}" )
  192. VCPKG_ROOT=$( ${{ steps.vars.outputs.PATHCONVERT }} "${VCPKG_ROOT}" )
  193. SOURCE_DIR=$( ${{ steps.vars.outputs.PATHCONVERT }} "${WORKSPACE}" )
  194. source ./scripts/version_number.sh
  195. source ./scripts/ci/generate-version-details.sh
  196. overlay_ports=(${WORKSPACE}/${{ steps.vars.outputs.OVERLAY }} ${WORKSPACE}/vcpkg/overlay)
  197. echo "Building with $(IFS=\; ; echo "${overlay_ports[*]}")"
  198. cmake -S "${SOURCE_DIR}" \
  199. -B "${CMAKE_BUILD_DIR}" \
  200. -DCMAKE_BUILD_TYPE=${{ steps.vars.outputs.BUILD_TYPE }} \
  201. -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
  202. -DVCPKG_OVERLAY_PORTS=$(IFS=\; ; echo "${overlay_ports[*]}") \
  203. -DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
  204. -DWITH_VCPKG=ON \
  205. -DWITH_SPIX=ON \
  206. -DAPP_VERSION="${APP_VERSION}" \
  207. -DAPP_VERSION_STR="${APP_VERSION_STR}" \
  208. -DAPP_PACKAGE_NAME="${APP_PACKAGE_NAME}" \
  209. -DENABLE_TESTS=ON \
  210. ${EXTRA_CMAKE_ARGS}
  211. - name: 📑 Upload Build Logs
  212. uses: actions/upload-artifact@v2
  213. if: failure()
  214. with:
  215. name: build-logs-${{ matrix.triplet }}
  216. path: ${{ steps.vars.outputs.VCPKG_ROOT }}/buildtrees/**/*.log
  217. - name: 🌋 Build
  218. run: |
  219. cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config ${{ steps.vars.outputs.BUILD_TYPE }} # --target qfield
  220. - name: 🧫 Test
  221. shell: bash
  222. env:
  223. WORKSPACE: ${{ github.workspace }}
  224. run: |
  225. SOURCE_DIR=$( ${{ steps.vars.outputs.PATHCONVERT }} "${WORKSPACE}" )
  226. pip install -r "${SOURCE_DIR}/test/spix/requirements.txt"
  227. cd "${{ env.CMAKE_BUILD_DIR }}"
  228. ${TESTWRAPPER} ctest --output-on-failure -E '${{ steps.vars.outputs.EXCLUDE_TESTS }}' -C ${{ steps.vars.outputs.BUILD_TYPE }}
  229. - name: Package
  230. shell: bash
  231. run: |
  232. export LD_LIBRARY_PATH="${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/${{ matrix.triplet }}/lib/":${LD_LIBRARY_PATH}
  233. cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target bundle --config Release
  234. case ${{ matrix.triplet }} in
  235. x64-linux)
  236. echo "ARTIFACT_PATHNAME=${{ env.CMAKE_BUILD_DIR }}/QField-x86_64.AppImage" >> $GITHUB_ENV
  237. echo "ARTIFACT_NAME=${{ steps.vars.outputs.CI_PACKAGE_FILE_BASENAME }}-linux-x64.AppImage" >> $GITHUB_ENV
  238. ;;
  239. x64-windows)
  240. ARTIFACT_PATHNAME=$(ls ${{ env.CMAKE_BUILD_DIR }}/QField-*-win64.* | head -n 1)
  241. ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
  242. echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
  243. echo "ARTIFACT_NAME=${{ steps.vars.outputs.CI_PACKAGE_FILE_BASENAME }}-windows-x64.exe" >> $GITHUB_ENV
  244. ;;
  245. esac
  246. - name: 📑 Upload Package Logs
  247. uses: actions/upload-artifact@v2
  248. if: failure()
  249. with:
  250. name: package-logs-${{ matrix.triplet }}
  251. path: ${{ steps.vars.outputs.BUILD_ROOT }}/builddir/_CPack_Packages/**/*.log
  252. - name: 📦 Upload package
  253. if: ${{ env.ARTIFACT_NAME != null }}
  254. uses: actions/upload-artifact@v2
  255. with:
  256. name: "QField-dev-${{ matrix.triplet }}-${{ steps.vars.outputs.BUILD_TYPE }}"
  257. path: ${{ env.ARTIFACT_PATHNAME }}
  258. - name: 📊 Upload test report
  259. uses: actions/upload-artifact@v2
  260. with:
  261. name: "test-report-${{ matrix.triplet }}-${{ steps.vars.outputs.BUILD_TYPE }}"
  262. path: "${{ env.CMAKE_BUILD_DIR }}/report"
  263. - name: 🪔 Get the current release version
  264. id: get_version
  265. shell: bash
  266. run: |
  267. echo "::set-output name=version::${GITHUB_REF##*/}"
  268. - name: 🚀 Upload Release Asset
  269. if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') && env.ARTIFACT_NAME != null
  270. uses: shogo82148/actions-upload-release-asset@v1
  271. with:
  272. upload_url: ${{ github.event.release.upload_url }}
  273. asset_path: ${{ env.ARTIFACT_PATHNAME }}
  274. asset_name: ${{ env.ARTIFACT_NAME }}
  275. overwrite: true