linux.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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-12 on ubuntu-22.04
  118. if: ${{ startsWith(inputs.operating_system, 'ubuntu-22.04') }}
  119. run: |
  120. sudo apt install g++-12 gcc-12 -y
  121. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
  122. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
  123. - name: Use GCC-10 on ubuntu-20.04
  124. if: ${{ startsWith(inputs.operating_system, 'ubuntu-20.04') }}
  125. run: |
  126. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
  127. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
  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: Set Environment variables for Cura (bash)
  141. run: |
  142. . ./cura_inst/bin/activate_github_actions_env.sh
  143. . ./cura_inst/bin/activate_github_actions_version_env.sh
  144. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  145. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  146. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  147. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  148. - name: Install OpenSSL shared
  149. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  150. - name: Copy OpenSSL shared (Bash)
  151. run: |
  152. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  153. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  154. - name: Create the Cura dist
  155. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  156. - name: Output the name file name and extension
  157. id: filename
  158. shell: python
  159. run: |
  160. import os
  161. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  162. if "${{ inputs.operating_system }}" == "ubuntu-22.04":
  163. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-linux-modern-${{ inputs.architecture }}"
  164. else:
  165. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-linux-${{ inputs.architecture }}"
  166. output_env = os.environ["GITHUB_OUTPUT"]
  167. content = ""
  168. if os.path.exists(output_env):
  169. with open(output_env, "r") as f:
  170. content = f.read()
  171. with open(output_env, "w") as f:
  172. f.write(content)
  173. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  174. - name: Summarize the used Conan dependencies
  175. shell: python
  176. run: |
  177. import os
  178. import json
  179. from pathlib import Path
  180. conan_install_info_path = Path("cura_inst/conan_install_info.json")
  181. conan_info = {"installed": []}
  182. if os.path.exists(conan_install_info_path):
  183. with open(conan_install_info_path, "r") as f:
  184. conan_info = json.load(f)
  185. sorted_deps = sorted([dep["recipe"]["id"].replace('#', r' rev: ') for dep in conan_info["installed"]])
  186. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  187. content = ""
  188. if os.path.exists(summary_env):
  189. with open(summary_env, "r") as f:
  190. content = f.read()
  191. with open(summary_env, "w") as f:
  192. f.write(content)
  193. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  194. f.writelines("## Conan packages:\n")
  195. for dep in sorted_deps:
  196. f.writelines(f"`{dep}`\n")
  197. - name: Summarize the used Python modules
  198. shell: python
  199. run: |
  200. import os
  201. import pkg_resources
  202. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  203. content = ""
  204. if os.path.exists(summary_env):
  205. with open(summary_env, "r") as f:
  206. content = f.read()
  207. with open(summary_env, "w") as f:
  208. f.write(content)
  209. f.writelines("## Python modules:\n")
  210. for package in pkg_resources.working_set:
  211. f.writelines(f"`{package.key}/{package.version}`\n")
  212. - name: Create the Linux AppImage (Bash)
  213. run: |
  214. python ../cura_inst/packaging/AppImage/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  215. chmod +x "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  216. working-directory: dist
  217. - name: Upload the AppImage
  218. uses: actions/upload-artifact@v3
  219. with:
  220. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-AppImage
  221. path: |
  222. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage
  223. retention-days: 5
  224. notify-export:
  225. if: ${{ always() }}
  226. needs: [ cura-installer-create ]
  227. uses: ultimaker/cura/.github/workflows/notify.yml@main
  228. with:
  229. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  230. success_title: "Create the Cura distributions"
  231. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  232. failure_title: "Failed to create the Cura distributions"
  233. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  234. secrets: inherit