linux.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. name: Linux Installer
  2. run-name: ${{ inputs.cura_conan_version }} for Linux-${{ inputs.architecture }} by @${{ github.actor }}
  3. on:
  4. workflow_dispatch:
  5. inputs:
  6. cura_conan_version:
  7. description: 'Cura Conan Version'
  8. default: 'cura/latest@ultimaker/testing'
  9. required: true
  10. type: string
  11. conan_args:
  12. description: 'Conan args: eq.: --require-override'
  13. default: ''
  14. required: false
  15. type: string
  16. enterprise:
  17. description: 'Build Cura as an Enterprise edition'
  18. default: false
  19. required: true
  20. type: boolean
  21. staging:
  22. description: 'Use staging API'
  23. default: false
  24. required: true
  25. type: boolean
  26. architecture:
  27. description: 'Architecture'
  28. required: true
  29. default: 'X64'
  30. type: choice
  31. options:
  32. - X64
  33. operating_system:
  34. description: 'OS'
  35. required: true
  36. default: 'ubuntu-22.04'
  37. type: choice
  38. options:
  39. - ubuntu-22.04
  40. workflow_call:
  41. inputs:
  42. cura_conan_version:
  43. description: 'Cura Conan Version'
  44. default: 'cura/latest@ultimaker/testing'
  45. required: true
  46. type: string
  47. conan_args:
  48. description: 'Conan args: eq.: --require-override'
  49. default: ''
  50. required: false
  51. type: string
  52. enterprise:
  53. description: 'Build Cura as an Enterprise edition'
  54. default: false
  55. required: true
  56. type: boolean
  57. staging:
  58. description: 'Use staging API'
  59. default: false
  60. required: true
  61. type: boolean
  62. architecture:
  63. description: 'Architecture'
  64. required: true
  65. default: 'X64'
  66. type: string
  67. operating_system:
  68. description: 'OS'
  69. required: true
  70. default: 'ubuntu-22.04'
  71. type: string
  72. env:
  73. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  74. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  75. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  76. CURA_CONAN_VERSION: ${{ inputs.cura_conan_version }}
  77. ENTERPRISE: ${{ inputs.enterprise }}
  78. STAGING: ${{ inputs.staging }}
  79. jobs:
  80. cura-installer-create:
  81. runs-on: ${{ inputs.operating_system }}
  82. steps:
  83. - name: Checkout
  84. uses: actions/checkout@v3
  85. - name: Setup Python and pip
  86. uses: actions/setup-python@v4
  87. with:
  88. python-version: '3.10.x'
  89. cache: 'pip'
  90. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  91. - name: Install Python requirements for runner
  92. run: pip install -r .github/workflows/requirements-conan-package.txt
  93. - name: Cache Conan local repository packages (Bash)
  94. uses: actions/cache@v3
  95. with:
  96. path: |
  97. $HOME/.conan/data
  98. $HOME/.conan/conan_download_cache
  99. key: conan-${{ runner.os }}-${{ runner.arch }}-installer-cache
  100. - name: Hack needed specifically for ubuntu-22.04 from mid-Feb 2023 onwards
  101. if: ${{ startsWith(inputs.operating_system, 'ubuntu-22.04') }}
  102. run: sudo apt remove libodbc2 libodbcinst2 unixodbc-common -y
  103. # NOTE: Due to what are probably github issues, we have to remove the cache and reconfigure before the rest.
  104. # This is maybe because grub caches the disk it uses last time, which is recreated each time.
  105. - name: Install Linux system requirements
  106. run: |
  107. sudo rm /var/cache/debconf/config.dat
  108. sudo dpkg --configure -a
  109. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  110. sudo apt update
  111. sudo apt upgrade
  112. sudo apt install build-essential checkinstall libegl-dev zlib1g-dev libssl-dev ninja-build autoconf libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev libxkbcommon-x11-dev pkg-config binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf squashfs-tools strace util-linux zsync -y
  113. # Get the AppImage tool
  114. wget --no-check-certificate --quiet https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O $GITHUB_WORKSPACE/appimagetool
  115. chmod +x $GITHUB_WORKSPACE/appimagetool
  116. echo "APPIMAGETOOL_LOCATION=$GITHUB_WORKSPACE/appimagetool" >> $GITHUB_ENV
  117. # Get the AppImage builder
  118. wget --no-check-certificate --quiet -O $GITHUB_WORKSPACE/appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
  119. chmod +x appimage-builder-x86_64.AppImage
  120. echo "APPIMAGEBUILDER_LOCATION=$GITHUB_WORKSPACE/appimage-builder-x86_64.AppImage" >> $GITHUB_ENV
  121. # Make sure these tools can be found on the path
  122. echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH
  123. - name: Install GCC-13
  124. run: |
  125. sudo apt install g++-13 gcc-13 -y
  126. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
  127. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
  128. - name: Create the default Conan profile
  129. run: conan profile new default --detect --force
  130. - name: Configure GPG Key Linux (Bash)
  131. run: echo -n "$GPG_PRIVATE_KEY" | base64 --decode | gpg --import
  132. - name: Get Conan configuration
  133. run: |
  134. conan config install https://github.com/Ultimaker/conan-config.git
  135. conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
  136. - name: Use Conan download cache (Bash)
  137. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  138. - name: Create the Packages (Bash)
  139. run: conan install $CURA_CONAN_VERSION ${{ inputs.conan_args }} --build=missing --update -if cura_inst -g VirtualPythonEnv -o cura:enterprise=$ENTERPRISE -o cura:staging=$STAGING --json "cura_inst/conan_install_info.json"
  140. - name: Upload the Package(s)
  141. if: always()
  142. run: |
  143. conan upload "*" -r cura --all -c
  144. - name: Set Environment variables for Cura (bash)
  145. run: |
  146. . ./cura_inst/bin/activate_github_actions_env.sh
  147. . ./cura_inst/bin/activate_github_actions_version_env.sh
  148. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  149. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  150. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  151. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  152. - name: Install OpenSSL shared
  153. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  154. - name: Copy OpenSSL shared (Bash)
  155. run: |
  156. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  157. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  158. - name: Create the Cura dist
  159. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  160. - name: Output the name file name and extension
  161. id: filename
  162. shell: python
  163. run: |
  164. import os
  165. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  166. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-linux-${{ inputs.architecture }}"
  167. output_env = os.environ["GITHUB_OUTPUT"]
  168. content = ""
  169. if os.path.exists(output_env):
  170. with open(output_env, "r") as f:
  171. content = f.read()
  172. with open(output_env, "w") as f:
  173. f.write(content)
  174. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  175. - name: Summarize the used Conan dependencies
  176. shell: python
  177. run: |
  178. import os
  179. import json
  180. from pathlib import Path
  181. conan_install_info_path = Path("cura_inst/conan_install_info.json")
  182. conan_info = {"installed": []}
  183. if os.path.exists(conan_install_info_path):
  184. with open(conan_install_info_path, "r") as f:
  185. conan_info = json.load(f)
  186. sorted_deps = sorted([dep["recipe"]["id"].replace('#', r' rev: ') for dep in conan_info["installed"]])
  187. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  188. content = ""
  189. if os.path.exists(summary_env):
  190. with open(summary_env, "r") as f:
  191. content = f.read()
  192. with open(summary_env, "w") as f:
  193. f.write(content)
  194. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  195. f.writelines("## Conan packages:\n")
  196. for dep in sorted_deps:
  197. f.writelines(f"`{dep}`\n")
  198. - name: Summarize the used Python modules
  199. shell: python
  200. run: |
  201. import os
  202. import pkg_resources
  203. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  204. content = ""
  205. if os.path.exists(summary_env):
  206. with open(summary_env, "r") as f:
  207. content = f.read()
  208. with open(summary_env, "w") as f:
  209. f.write(content)
  210. f.writelines("## Python modules:\n")
  211. for package in pkg_resources.working_set:
  212. f.writelines(f"`{package.key}/{package.version}`\n")
  213. - name: Create the Linux AppImage (Bash)
  214. run: |
  215. python ../cura_inst/packaging/AppImage-builder/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  216. chmod +x "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  217. working-directory: dist
  218. - name: Upload the AppImage
  219. uses: actions/upload-artifact@v3
  220. with:
  221. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-AppImage
  222. path: |
  223. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage
  224. retention-days: 5
  225. - name: Write the run info
  226. shell: python
  227. run: |
  228. import os
  229. with open("run_info.sh", "w") as f:
  230. f.writelines(f'echo "CURA_VERSION_FULL={os.environ["CURA_VERSION_FULL"]}" >> $GITHUB_ENV\n')
  231. - name: Upload the run info
  232. uses: actions/upload-artifact@v3
  233. with:
  234. name: linux-run-info
  235. path: |
  236. run_info.sh
  237. retention-days: 5
  238. notify-export:
  239. if: ${{ always() }}
  240. needs: [ cura-installer-create ]
  241. uses: ultimaker/cura/.github/workflows/notify.yml@main
  242. with:
  243. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  244. success_title: "Create the Cura distributions"
  245. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  246. failure_title: "Failed to create the Cura distributions"
  247. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  248. secrets: inherit