cura-installer.yml 18 KB

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