linux.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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
  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. from cura.CuraVersion import ConanInstalls
  182. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  183. content = ""
  184. if os.path.exists(summary_env):
  185. with open(summary_env, "r") as f:
  186. content = f.read()
  187. with open(summary_env, "w") as f:
  188. f.write(content)
  189. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  190. f.writelines("## Conan packages:\n")
  191. for dep_name, dep_info in ConanDependencies.items():
  192. f.writelines(f"`{dep_name} {dep_info["version"]} {dep_info["revision"]}`\n")
  193. - name: Summarize the used Python modules
  194. shell: python
  195. run: |
  196. import os
  197. import pkg_resources
  198. from cura.CuraVersion import ConanDependencies
  199. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  200. content = ""
  201. if os.path.exists(summary_env):
  202. with open(summary_env, "r") as f:
  203. content = f.read()
  204. with open(summary_env, "w") as f:
  205. f.write(content)
  206. f.writelines("## Python modules:\n")
  207. for dep_name, dep_info in ConanDependencies.items():
  208. f.writelines(f"`{dep_name} {dep_info["version"]}`\n")
  209. - name: Create the Linux AppImage (Bash)
  210. run: |
  211. python ../cura_inst/packaging/AppImage-builder/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  212. chmod +x "${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage"
  213. working-directory: dist
  214. - name: Upload the AppImage
  215. uses: actions/upload-artifact@v3
  216. with:
  217. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-AppImage
  218. path: |
  219. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage
  220. retention-days: 5
  221. - name: Upload the asc
  222. uses: actions/upload-artifact@v3
  223. with:
  224. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-asc
  225. path: |
  226. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.AppImage.asc
  227. retention-days: 5
  228. - name: Write the run info
  229. shell: python
  230. run: |
  231. import os
  232. with open("run_info.sh", "w") as f:
  233. f.writelines(f'echo "CURA_VERSION_FULL={os.environ["CURA_VERSION_FULL"]}" >> $GITHUB_ENV\n')
  234. - name: Upload the run info
  235. uses: actions/upload-artifact@v3
  236. with:
  237. name: linux-run-info
  238. path: |
  239. run_info.sh
  240. retention-days: 5
  241. notify-export:
  242. if: ${{ always() }}
  243. needs: [ cura-installer-create ]
  244. uses: ultimaker/cura/.github/workflows/notify.yml@main
  245. with:
  246. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  247. success_title: "Create the Cura distributions"
  248. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  249. failure_title: "Failed to create the Cura distributions"
  250. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  251. secrets: inherit