linux.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. - ubuntu-20.04
  41. workflow_call:
  42. inputs:
  43. cura_conan_version:
  44. description: 'Cura Conan Version'
  45. default: 'cura/latest@ultimaker/testing'
  46. required: true
  47. type: string
  48. conan_args:
  49. description: 'Conan args: eq.: --require-override'
  50. default: ''
  51. required: false
  52. type: string
  53. enterprise:
  54. description: 'Build Cura as an Enterprise edition'
  55. default: false
  56. required: true
  57. type: boolean
  58. staging:
  59. description: 'Use staging API'
  60. default: false
  61. required: true
  62. type: boolean
  63. architecture:
  64. description: 'Architecture'
  65. required: true
  66. default: 'X64'
  67. type: string
  68. operating_system:
  69. description: 'OS'
  70. required: true
  71. default: 'ubuntu-22.04'
  72. type: string
  73. env:
  74. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  75. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  76. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  77. CURA_CONAN_VERSION: ${{ inputs.cura_conan_version }}
  78. ENTERPRISE: ${{ inputs.enterprise }}
  79. STAGING: ${{ inputs.staging }}
  80. jobs:
  81. cura-installer-create:
  82. runs-on: ${{ inputs.operating_system }}
  83. steps:
  84. - name: Checkout
  85. uses: actions/checkout@v3
  86. - name: Setup Python and pip
  87. uses: actions/setup-python@v4
  88. with:
  89. python-version: '3.10.x'
  90. cache: 'pip'
  91. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  92. - name: Install Python requirements for runner
  93. run: pip install -r .github/workflows/requirements-conan-package.txt
  94. - name: Cache Conan local repository packages (Bash)
  95. uses: actions/cache@v3
  96. with:
  97. path: |
  98. $HOME/.conan/data
  99. $HOME/.conan/conan_download_cache
  100. key: conan-${{ runner.os }}-${{ runner.arch }}-installer-cache
  101. - name: Hack needed specifically for ubuntu-22.04 from mid-Feb 2023 onwards
  102. if: ${{ startsWith(inputs.operating_system, 'ubuntu-22.04') }}
  103. run: sudo apt remove libodbc2 libodbcinst2 unixodbc-common -y
  104. # NOTE: Due to what are probably github issues, we have to remove the cache and reconfigure before the rest.
  105. # This is maybe because grub caches the disk it uses last time, which is recreated each time.
  106. - name: Install Linux system requirements
  107. run: |
  108. sudo rm /var/cache/debconf/config.dat
  109. sudo dpkg --configure -a
  110. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  111. sudo apt update
  112. sudo apt upgrade
  113. 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 -y
  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. - name: Install GCC-13
  118. run: |
  119. sudo apt install g++-13 gcc-13 -y
  120. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
  121. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
  122. - name: Create the default Conan profile
  123. run: conan profile new default --detect --force
  124. - name: Configure GPG Key Linux (Bash)
  125. run: echo -n "$GPG_PRIVATE_KEY" | base64 --decode | gpg --import
  126. - name: Get Conan configuration
  127. run: |
  128. conan config install https://github.com/Ultimaker/conan-config.git
  129. conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
  130. - name: Use Conan download cache (Bash)
  131. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  132. - name: Create the Packages (Bash)
  133. 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"
  134. - name: Upload the Package(s)
  135. if: always()
  136. run: |
  137. conan upload "*" -r cura --all -c
  138. - name: Set Environment variables for Cura (bash)
  139. run: |
  140. . ./cura_inst/bin/activate_github_actions_env.sh
  141. . ./cura_inst/bin/activate_github_actions_version_env.sh
  142. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  143. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  144. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  145. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  146. - name: Install OpenSSL shared
  147. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  148. - name: Copy OpenSSL shared (Bash)
  149. run: |
  150. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  151. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  152. - name: Create the Cura dist
  153. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  154. - name: Output the name file name and extension
  155. id: filename
  156. shell: python
  157. run: |
  158. import os
  159. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  160. if "${{ inputs.operating_system }}" == "ubuntu-22.04":
  161. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-linux-modern-${{ inputs.architecture }}"
  162. else:
  163. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-linux-${{ inputs.architecture }}"
  164. output_env = os.environ["GITHUB_OUTPUT"]
  165. content = ""
  166. if os.path.exists(output_env):
  167. with open(output_env, "r") as f:
  168. content = f.read()
  169. with open(output_env, "w") as f:
  170. f.write(content)
  171. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  172. - name: Summarize the used Conan dependencies
  173. shell: python
  174. run: |
  175. import os
  176. import json
  177. from pathlib import Path
  178. conan_install_info_path = Path("cura_inst/conan_install_info.json")
  179. conan_info = {"installed": []}
  180. if os.path.exists(conan_install_info_path):
  181. with open(conan_install_info_path, "r") as f:
  182. conan_info = json.load(f)
  183. sorted_deps = sorted([dep["recipe"]["id"].replace('#', r' rev: ') for dep in conan_info["installed"]])
  184. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  185. content = ""
  186. if os.path.exists(summary_env):
  187. with open(summary_env, "r") as f:
  188. content = f.read()
  189. with open(summary_env, "w") as f:
  190. f.write(content)
  191. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  192. f.writelines("## Conan packages:\n")
  193. for dep in sorted_deps:
  194. f.writelines(f"`{dep}`\n")
  195. - name: Summarize the used Python modules
  196. shell: python
  197. run: |
  198. import os
  199. import pkg_resources
  200. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  201. content = ""
  202. if os.path.exists(summary_env):
  203. with open(summary_env, "r") as f:
  204. content = f.read()
  205. with open(summary_env, "w") as f:
  206. f.write(content)
  207. f.writelines("## Python modules:\n")
  208. for package in pkg_resources.working_set:
  209. f.writelines(f"`{package.key}/{package.version}`\n")
  210. - name: Create the Linux AppImage (Bash)
  211. run: |
  212. python ../cura_inst/packaging/AppImage/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  213. chmod +x "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  214. working-directory: dist
  215. - name: Upload the AppImage
  216. uses: actions/upload-artifact@v3
  217. with:
  218. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-AppImage
  219. path: |
  220. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage
  221. retention-days: 5
  222. notify-export:
  223. if: ${{ always() }}
  224. needs: [ cura-installer-create ]
  225. uses: ultimaker/cura/.github/workflows/notify.yml@main
  226. with:
  227. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  228. success_title: "Create the Cura distributions"
  229. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  230. failure_title: "Failed to create the Cura distributions"
  231. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  232. secrets: inherit