cura-installer.yml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. name: Cura Installer
  2. run-name: ${{ inputs.cura_conan_version }} for ${{ inputs.platform }} by @${{ github.actor }}
  3. on:
  4. workflow_call:
  5. inputs:
  6. platform:
  7. description: 'Selected Installer OS'
  8. default: 'ubuntu-20.04'
  9. required: true
  10. type: string
  11. os_name:
  12. description: 'OS Friendly Name'
  13. default: 'linux'
  14. required: true
  15. type: string
  16. cura_conan_version:
  17. description: 'Cura Conan Version'
  18. default: 'cura/latest@ultimaker/testing'
  19. required: true
  20. type: string
  21. conan_args:
  22. description: 'Conan args: eq.: --require-override'
  23. default: ''
  24. required: false
  25. type: string
  26. conan_config:
  27. description: 'Conan config branch to use'
  28. default: ''
  29. required: false
  30. type: string
  31. enterprise:
  32. description: 'Build Cura as an Enterprise edition'
  33. default: false
  34. required: true
  35. type: boolean
  36. staging:
  37. description: 'Use staging API'
  38. default: false
  39. required: true
  40. type: boolean
  41. installer:
  42. description: 'Create the installer'
  43. default: true
  44. required: true
  45. type: boolean
  46. msi_installer:
  47. description: 'Create the msi'
  48. default: false
  49. required: true
  50. type: boolean
  51. env:
  52. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  53. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  54. CONAN_LOGIN_USERNAME_CURA_CE: ${{ secrets.CONAN_USER }}
  55. CONAN_PASSWORD_CURA_CE: ${{ secrets.CONAN_PASS }}
  56. CONAN_LOG_RUN_TO_OUTPUT: 1
  57. CONAN_LOGGING_LEVEL: ${{ inputs.conan_logging_level }}
  58. CONAN_NON_INTERACTIVE: 1
  59. CODESIGN_IDENTITY: ${{ secrets.CODESIGN_IDENTITY }}
  60. MAC_NOTARIZE_USER: ${{ secrets.MAC_NOTARIZE_USER }}
  61. MAC_NOTARIZE_PASS: ${{ secrets.MAC_NOTARIZE_PASS }}
  62. MACOS_CERT_P12: ${{ secrets.MACOS_CERT_P12 }}
  63. MACOS_CERT_INSTALLER_P12: ${{ secrets.MACOS_CERT_INSTALLER_P12 }}
  64. MACOS_CERT_USER: ${{ secrets.MACOS_CERT_USER }}
  65. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  66. MACOS_CERT_PASSPHRASE: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  67. WIN_CERT_INSTALLER_CER: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  68. WIN_CERT_INSTALLER_CER_PASS: ${{ secrets.WIN_CERT_INSTALLER_CER_PASS }}
  69. CURA_CONAN_VERSION: ${{ inputs.cura_conan_version }}
  70. ENTERPRISE: ${{ inputs.enterprise }}
  71. STAGING: ${{ inputs.staging }}
  72. jobs:
  73. cura-installer-create:
  74. runs-on: ${{ inputs.platform }}
  75. steps:
  76. - name: Checkout
  77. uses: actions/checkout@v3
  78. - name: Setup Python and pip
  79. uses: actions/setup-python@v4
  80. with:
  81. python-version: '3.10.x'
  82. cache: 'pip'
  83. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  84. - name: Install Python requirements for runner
  85. run: pip install -r https://raw.githubusercontent.com/Ultimaker/Cura/main/.github/workflows/requirements-conan-package.txt
  86. # Note the runner requirements are always installed from the main branch in the Ultimaker/Cura repo
  87. - name: Use Conan download cache (Bash)
  88. if: ${{ runner.os != 'Windows' }}
  89. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  90. - name: Use Conan download cache (Powershell)
  91. if: ${{ runner.os == 'Windows' }}
  92. run: conan config set storage.download_cache="C:\Users\runneradmin\.conan\conan_download_cache"
  93. - name: Cache Conan local repository packages (Bash)
  94. uses: actions/cache@v3
  95. if: ${{ runner.os != 'Windows' }}
  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: Cache Conan local repository packages (Powershell)
  102. uses: actions/cache@v3
  103. if: ${{ runner.os == 'Windows' }}
  104. with:
  105. path: |
  106. C:\Users\runneradmin\.conan\data
  107. C:\.conan
  108. C:\Users\runneradmin\.conan\conan_download_cache
  109. key: conan-${{ runner.os }}-${{ runner.arch }}-installer-cache
  110. - name: Install MacOS system requirements
  111. if: ${{ runner.os == 'Macos' }}
  112. run: brew install autoconf automake ninja create-dmg # Delete create-dmg when deprecating dmg
  113. - name: Hack needed specifically for ubuntu-22.04 from mid-Feb 2023 onwards
  114. if: ${{ runner.os == 'Linux' && startsWith(inputs.platform, 'ubuntu-22.04') }}
  115. run: sudo apt remove libodbc2 libodbcinst2 unixodbc-common -y
  116. # NOTE: Due to what are probably github issues, we have to remove the cache and reconfigure before the rest.
  117. # This is maybe because grub caches the disk it uses last time, which is recreated each time.
  118. - name: Install Linux system requirements
  119. if: ${{ runner.os == 'Linux' }}
  120. run: |
  121. sudo rm /var/cache/debconf/config.dat
  122. sudo dpkg --configure -a
  123. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  124. sudo apt update
  125. sudo apt upgrade
  126. 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
  127. wget --no-check-certificate --quiet https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O $GITHUB_WORKSPACE/appimagetool
  128. chmod +x $GITHUB_WORKSPACE/appimagetool
  129. echo "APPIMAGETOOL_LOCATION=$GITHUB_WORKSPACE/appimagetool" >> $GITHUB_ENV
  130. - name: Install GCC-12 on ubuntu-22.04
  131. if: ${{ startsWith(inputs.platform, 'ubuntu-22.04') }}
  132. run: |
  133. sudo apt install g++-12 gcc-12 -y
  134. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
  135. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
  136. - name: Use GCC-10 on ubuntu-20.04
  137. if: ${{ startsWith(inputs.platform, 'ubuntu-20.04') }}
  138. run: |
  139. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
  140. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
  141. - name: Create the default Conan profile
  142. run: conan profile new default --detect
  143. - name: Configure GPG Key Linux (Bash)
  144. if: ${{ runner.os == 'Linux' }}
  145. run: echo -n "$GPG_PRIVATE_KEY" | base64 --decode | gpg --import
  146. - name: Configure Macos keychain Developer Cert(Bash)
  147. id: macos-keychain-developer-cert
  148. if: ${{ runner.os == 'Macos' }}
  149. uses: apple-actions/import-codesign-certs@v1
  150. with:
  151. keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  152. p12-file-base64: ${{ secrets.MACOS_CERT_P12 }}
  153. p12-password: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  154. - name: Configure Macos keychain Installer Cert (Bash)
  155. id: macos-keychain-installer-cert
  156. if: ${{ runner.os == 'Macos' }}
  157. uses: apple-actions/import-codesign-certs@v1
  158. with:
  159. keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  160. create-keychain: false # keychain is created in previous use of action.
  161. p12-file-base64: ${{ secrets.MACOS_CERT_INSTALLER_P12 }}
  162. p12-password: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  163. - name: Create PFX certificate from BASE64_PFX_CONTENT secret
  164. if: ${{ runner.os == 'Windows' }}
  165. id: create-pfx
  166. env:
  167. PFX_CONTENT: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  168. run: |
  169. $pfxPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "cert.pfx";
  170. $encodedBytes = [System.Convert]::FromBase64String($env:PFX_CONTENT);
  171. Set-Content $pfxPath -Value $encodedBytes -AsByteStream;
  172. echo "PFX_PATH=$pfxPath" >> $env:GITHUB_OUTPUT;
  173. - name: Get Conan configuration from branch
  174. if: ${{ inputs.conan_config != '' }}
  175. run: conan config install https://github.com/Ultimaker/conan-config.git -a "-b ${{ inputs.conan_config }}"
  176. - name: Get Conan configuration
  177. if: ${{ inputs.conan_config == '' }}
  178. run: conan config install https://github.com/Ultimaker/conan-config.git
  179. - name: Create the Packages (Bash)
  180. if: ${{ runner.os != 'Windows' }}
  181. 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"
  182. - name: Create the Packages (Powershell)
  183. if: ${{ runner.os == 'Windows' }}
  184. run: conan install $Env:CURA_CONAN_VERSION ${{ inputs.conan_args }} --build=missing --update -if cura_inst -g VirtualPythonEnv -o cura:enterprise=$Env:ENTERPRISE -o cura:staging=$Env:STAGING --json "cura_inst/conan_install_info.json"
  185. - name: Set Environment variables for Cura (bash)
  186. if: ${{ runner.os != 'Windows' }}
  187. run: |
  188. . ./cura_inst/bin/activate_github_actions_env.sh
  189. . ./cura_inst/bin/activate_github_actions_version_env.sh
  190. - name: Set Environment variables for Cura (Powershell)
  191. if: ${{ runner.os == 'Windows' }}
  192. run: |
  193. echo "${Env:WIX}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  194. .\cura_inst\Scripts\activate_github_actions_env.ps1
  195. .\cura_inst\Scripts\activate_github_actions_version_env.ps1
  196. - name: Unlock Macos keychain (Bash)
  197. if: ${{ runner.os == 'Macos' }}
  198. run: security unlock -p $TEMP_KEYCHAIN_PASSWORD signing_temp.keychain
  199. env:
  200. TEMP_KEYCHAIN_PASSWORD: ${{ steps.macos-keychain-developer-cert.outputs.keychain-password }}
  201. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  202. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  203. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  204. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  205. - name: Install OpenSSL shared
  206. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  207. - name: Copy OpenSSL shared (Bash)
  208. if: ${{ runner.os != 'Windows' }}
  209. run: |
  210. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  211. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  212. - name: Copy OpenSSL shared (Powershell)
  213. if: ${{ runner.os == 'Windows' }}
  214. run: |
  215. cp openssl/bin/*.dll ./cura_inst/Scripts/
  216. cp openssl/lib/*.lib ./cura_inst/Lib/
  217. - name: Create the Cura dist
  218. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  219. - name: Output the name file name and extension
  220. id: filename
  221. shell: python
  222. run: |
  223. import os
  224. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  225. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-${{ inputs.os_name }}"
  226. if "${{ runner.os }}" == "Windows":
  227. installer_ext = "msi" if "${{ inputs.msi_installer }}" == "true" else "exe"
  228. elif "${{ runner.os }}" == "macOS":
  229. installer_ext = "pkg" if "${{ inputs.msi_installer }}" == "true" else "dmg"
  230. else:
  231. installer_ext = "AppImage"
  232. output_env = os.environ["GITHUB_OUTPUT"]
  233. content = ""
  234. if os.path.exists(output_env):
  235. with open(output_env, "r") as f:
  236. content = f.read()
  237. with open(output_env, "w") as f:
  238. f.write(content)
  239. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  240. f.writelines(f"INSTALLER_EXT={installer_ext}\n")
  241. f.writelines(f"FULL_INSTALLER_FILENAME={installer_filename}.{installer_ext}\n")
  242. - name: Summarize the used Conan dependencies
  243. shell: python
  244. run: |
  245. import os
  246. import json
  247. from pathlib import Path
  248. conan_install_info_path = Path("cura_inst/conan_install_info.json")
  249. conan_info = {"installed": []}
  250. if os.path.exists(conan_install_info_path):
  251. with open(conan_install_info_path, "r") as f:
  252. conan_info = json.load(f)
  253. sorted_deps = sorted([dep["recipe"]["id"].replace('#', r' rev: ') for dep in conan_info["installed"]])
  254. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  255. content = ""
  256. if os.path.exists(summary_env):
  257. with open(summary_env, "r") as f:
  258. content = f.read()
  259. with open(summary_env, "w") as f:
  260. f.write(content)
  261. f.writelines("# ${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}\n")
  262. f.writelines("## Conan packages:\n")
  263. for dep in sorted_deps:
  264. f.writelines(f"`{dep}`\n")
  265. - name: Summarize the used Python modules
  266. shell: python
  267. run: |
  268. import os
  269. import pkg_resources
  270. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  271. content = ""
  272. if os.path.exists(summary_env):
  273. with open(summary_env, "r") as f:
  274. content = f.read()
  275. with open(summary_env, "w") as f:
  276. f.write(content)
  277. f.writelines("## Python modules:\n")
  278. for package in pkg_resources.working_set:
  279. f.writelines(f"`{package.key}/{package.version}`\n")
  280. - name: Archive the artifacts (bash)
  281. if: ${{ !inputs.installer && runner.os != 'Windows' }}
  282. run: tar -zcf "./${{ steps.filename.outputs.INSTALLER_FILENAME }}.tar.gz" "./UltiMaker-Cura/"
  283. working-directory: dist
  284. - name: Archive the artifacts (Powershell)
  285. if: ${{ !inputs.installer && runner.os == 'Windows' }}
  286. run: Compress-Archive -Path ".\UltiMaker-Cura" -DestinationPath ".\${{ steps.filename.outputs.INSTALLER_FILENAME }}.zip"
  287. working-directory: dist
  288. - name: Create the Windows exe installer (Powershell)
  289. if: ${{ inputs.installer && runner.os == 'Windows' && !inputs.msi_installer }}
  290. run: |
  291. python ..\cura_inst\packaging\NSIS\create_windows_installer.py ../cura_inst . "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
  292. working-directory: dist
  293. - name: Create the Windows msi installer (Powershell)
  294. if: ${{ inputs.installer && runner.os == 'Windows' && inputs.msi_installer }}
  295. run: |
  296. python ..\cura_inst\packaging\msi\create_windows_msi.py ..\cura_inst .\UltiMaker-Cura "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}" "$Env:CURA_APP_NAME"
  297. working-directory: dist
  298. - name: Sign the Windows exe installer (Powershell)
  299. if: ${{ inputs.installer && runner.os == 'Windows' && !inputs.msi_installer }}
  300. env:
  301. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  302. run: |
  303. & "C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe" sign /f $Env:PFX_PATH /p "$Env:WIN_CERT_INSTALLER_CER_PASS" /fd SHA256 /t http://timestamp.digicert.com "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
  304. working-directory: dist
  305. - name: Sign the Windows msi installer (Powershell)
  306. if: ${{ inputs.installer && runner.os == 'Windows' && inputs.msi_installer }}
  307. env:
  308. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  309. run: |
  310. & "C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe" sign /f $Env:PFX_PATH /p "$Env:WIN_CERT_INSTALLER_CER_PASS" /fd SHA256 /t http://timestamp.digicert.com "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
  311. working-directory: dist
  312. - name: Create the Linux AppImage (Bash)
  313. if: ${{ inputs.installer && runner.os == 'Linux' }}
  314. run: python ../cura_inst/packaging/AppImage/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
  315. working-directory: dist
  316. - name: Create the MacOS dmg and/or pkg (Bash)
  317. if: ${{ github.event.inputs.installer == 'true' && runner.os == 'Macos' }}
  318. run: python ../cura_inst/packaging/MacOS/build_macos.py ../cura_inst . $CURA_CONAN_VERSION "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}" "$CURA_APP_NAME"
  319. working-directory: dist
  320. - name: Upload the artifacts
  321. uses: actions/upload-artifact@v3
  322. with:
  323. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-${{ steps.filename.outputs.INSTALLER_EXT }}
  324. path: |
  325. dist/*.tar.gz
  326. dist/*.zip
  327. dist/${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}
  328. dist/*.asc
  329. retention-days: 5
  330. notify-export:
  331. if: ${{ always() }}
  332. needs: [ cura-installer-create ]
  333. uses: ultimaker/cura/.github/workflows/notify.yml@main
  334. with:
  335. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  336. success_title: "Create the Cura distributions"
  337. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  338. failure_title: "Failed to create the Cura distributions"
  339. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  340. secrets: inherit