cura-installer.yml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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: Install Linux system requirements
  114. if: ${{ runner.os == 'Linux' }}
  115. run: |
  116. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  117. sudo apt update
  118. sudo apt upgrade
  119. 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
  120. wget --no-check-certificate --quiet https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O $GITHUB_WORKSPACE/appimagetool
  121. chmod +x $GITHUB_WORKSPACE/appimagetool
  122. echo "APPIMAGETOOL_LOCATION=$GITHUB_WORKSPACE/appimagetool" >> $GITHUB_ENV
  123. - name: Install GCC-12 on ubuntu-22.04
  124. if: ${{ startsWith(inputs.platform, 'ubuntu-22.04') }}
  125. run: |
  126. sudo apt install g++-12 gcc-12 -y
  127. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
  128. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
  129. - name: Use GCC-10 on ubuntu-20.04
  130. if: ${{ startsWith(inputs.platform, 'ubuntu-20.04') }}
  131. run: |
  132. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
  133. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
  134. - name: Create the default Conan profile
  135. run: conan profile new default --detect
  136. - name: Configure GPG Key Linux (Bash)
  137. if: ${{ runner.os == 'Linux' }}
  138. run: echo -n "$GPG_PRIVATE_KEY" | base64 --decode | gpg --import
  139. - name: Configure Macos keychain Developer Cert(Bash)
  140. id: macos-keychain-developer-cert
  141. if: ${{ runner.os == 'Macos' }}
  142. uses: apple-actions/import-codesign-certs@v1
  143. with:
  144. keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  145. p12-file-base64: ${{ secrets.MACOS_CERT_P12 }}
  146. p12-password: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  147. - name: Configure Macos keychain Installer Cert (Bash)
  148. id: macos-keychain-installer-cert
  149. if: ${{ runner.os == 'Macos' }}
  150. uses: apple-actions/import-codesign-certs@v1
  151. with:
  152. keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  153. create-keychain: false # keychain is created in previous use of action.
  154. p12-file-base64: ${{ secrets.MACOS_CERT_INSTALLER_P12 }}
  155. p12-password: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  156. - name: Create PFX certificate from BASE64_PFX_CONTENT secret
  157. if: ${{ runner.os == 'Windows' }}
  158. id: create-pfx
  159. env:
  160. PFX_CONTENT: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  161. run: |
  162. $pfxPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "cert.pfx";
  163. $encodedBytes = [System.Convert]::FromBase64String($env:PFX_CONTENT);
  164. Set-Content $pfxPath -Value $encodedBytes -AsByteStream;
  165. echo "PFX_PATH=$pfxPath" >> $env:GITHUB_OUTPUT;
  166. - name: Get Conan configuration from branch
  167. if: ${{ inputs.conan_config != '' }}
  168. run: conan config install https://github.com/Ultimaker/conan-config.git -a "-b ${{ inputs.conan_config }}"
  169. - name: Get Conan configuration
  170. if: ${{ inputs.conan_config == '' }}
  171. run: conan config install https://github.com/Ultimaker/conan-config.git
  172. - name: Create the Packages (Bash)
  173. if: ${{ runner.os != 'Windows' }}
  174. 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"
  175. - name: Create the Packages (Powershell)
  176. if: ${{ runner.os == 'Windows' }}
  177. 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"
  178. - name: Set Environment variables for Cura (bash)
  179. if: ${{ runner.os != 'Windows' }}
  180. run: |
  181. . ./cura_inst/bin/activate_github_actions_env.sh
  182. . ./cura_inst/bin/activate_github_actions_version_env.sh
  183. - name: Set Environment variables for Cura (Powershell)
  184. if: ${{ runner.os == 'Windows' }}
  185. run: |
  186. echo "${Env:WIX}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  187. .\cura_inst\Scripts\activate_github_actions_env.ps1
  188. .\cura_inst\Scripts\activate_github_actions_version_env.ps1
  189. - name: Unlock Macos keychain (Bash)
  190. if: ${{ runner.os == 'Macos' }}
  191. run: security unlock -p $TEMP_KEYCHAIN_PASSWORD signing_temp.keychain
  192. env:
  193. TEMP_KEYCHAIN_PASSWORD: ${{ steps.macos-keychain-developer-cert.outputs.keychain-password }}
  194. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  195. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  196. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  197. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  198. - name: Install OpenSSL shared
  199. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  200. - name: Copy OpenSSL shared (Bash)
  201. if: ${{ runner.os != 'Windows' }}
  202. run: |
  203. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  204. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  205. - name: Copy OpenSSL shared (Powershell)
  206. if: ${{ runner.os == 'Windows' }}
  207. run: |
  208. cp openssl/bin/*.dll ./cura_inst/Scripts/
  209. cp openssl/lib/*.lib ./cura_inst/Lib/
  210. - name: Create the Cura dist
  211. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  212. - name: Output the name file name and extension
  213. id: filename
  214. shell: python
  215. run: |
  216. import os
  217. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  218. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-${{ inputs.os_name }}"
  219. if "${{ runner.os }}" == "Windows":
  220. installer_ext = "msi" if "${{ inputs.msi_installer }}" == "true" else "exe"
  221. elif "${{ runner.os }}" == "macOS":
  222. installer_ext = "pkg" if "${{ inputs.msi_installer }}" == "true" else "dmg"
  223. else:
  224. installer_ext = "AppImage"
  225. output_env = os.environ["GITHUB_OUTPUT"]
  226. content = ""
  227. if os.path.exists(output_env):
  228. with open(output_env, "r") as f:
  229. content = f.read()
  230. with open(output_env, "w") as f:
  231. f.write(content)
  232. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  233. f.writelines(f"INSTALLER_EXT={installer_ext}\n")
  234. f.writelines(f"FULL_INSTALLER_FILENAME={installer_filename}.{installer_ext}\n")
  235. - name: Archive the artifacts (bash)
  236. if: ${{ !inputs.installer && runner.os != 'Windows' }}
  237. run: tar -zcf "./${{ steps.filename.outputs.INSTALLER_FILENAME }}.tar.gz" "./UltiMaker-Cura/"
  238. working-directory: dist
  239. - name: Archive the artifacts (Powershell)
  240. if: ${{ !inputs.installer && runner.os == 'Windows' }}
  241. run: Compress-Archive -Path ".\UltiMaker-Cura" -DestinationPath ".\${{ steps.filename.outputs.INSTALLER_FILENAME }}.zip"
  242. working-directory: dist
  243. - name: Create the Windows exe installer (Powershell)
  244. if: ${{ inputs.installer && runner.os == 'Windows' && !inputs.msi_installer }}
  245. run: |
  246. python ..\cura_inst\packaging\NSIS\create_windows_installer.py ../cura_inst . "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
  247. working-directory: dist
  248. - name: Create the Windows msi installer (Powershell)
  249. if: ${{ inputs.installer && runner.os == 'Windows' && inputs.msi_installer }}
  250. run: |
  251. python ..\cura_inst\packaging\msi\create_windows_msi.py ..\cura_inst .\UltiMaker-Cura "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}" "$Env:CURA_APP_NAME"
  252. working-directory: dist
  253. - name: Sign the Windows exe installer (Powershell)
  254. if: ${{ inputs.installer && runner.os == 'Windows' && !inputs.msi_installer }}
  255. env:
  256. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  257. run: |
  258. & "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 }}"
  259. working-directory: dist
  260. - name: Sign the Windows msi installer (Powershell)
  261. if: ${{ inputs.installer && runner.os == 'Windows' && inputs.msi_installer }}
  262. env:
  263. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  264. run: |
  265. & "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 }}"
  266. working-directory: dist
  267. - name: Create the Linux AppImage (Bash)
  268. if: ${{ inputs.installer && runner.os == 'Linux' }}
  269. run: python ../cura_inst/packaging/AppImage/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
  270. working-directory: dist
  271. - name: Create the MacOS dmg and/or pkg (Bash)
  272. if: ${{ github.event.inputs.installer == 'true' && runner.os == 'Macos' }}
  273. run: python ../cura_inst/packaging/MacOS/build_macos.py ../cura_inst . $CURA_CONAN_VERSION "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}" "$CURA_APP_NAME"
  274. working-directory: dist
  275. - name: Upload the artifacts
  276. uses: actions/upload-artifact@v3
  277. with:
  278. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-${{ steps.filename.outputs.INSTALLER_EXT }}
  279. path: |
  280. dist/*.tar.gz
  281. dist/*.zip
  282. dist/${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}
  283. dist/*.asc
  284. retention-days: 5
  285. notify-export:
  286. if: ${{ always() }}
  287. needs: [ cura-installer-create ]
  288. uses: ultimaker/cura/.github/workflows/notify.yml@main
  289. with:
  290. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  291. success_title: "Create the Cura distributions"
  292. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  293. failure_title: "Failed to create the Cura distributions"
  294. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  295. secrets: inherit