windows.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. name: Windows Installer
  2. run-name: ${{ inputs.cura_conan_version }} for Windows-${{ 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: 'windows-2022'
  37. type: choice
  38. options:
  39. - windows-2022
  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: 'windows-2022'
  71. type: string
  72. env:
  73. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  74. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  75. WIN_CERT_INSTALLER_CER: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  76. WIN_CERT_INSTALLER_CER_PASS: ${{ secrets.WIN_CERT_INSTALLER_CER_PASS }}
  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. outputs:
  84. INSTALLER_FILENAME: ${{ steps.filename.outputs.INSTALLER_FILENAME }}
  85. steps:
  86. - name: Checkout
  87. uses: actions/checkout@v3
  88. - name: Setup Python and pip
  89. uses: actions/setup-python@v4
  90. with:
  91. python-version: '3.10.x'
  92. cache: 'pip'
  93. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  94. - name: Install Python requirements for runner
  95. run: pip install -r .github/workflows/requirements-conan-package.txt
  96. - name: Cache Conan local repository packages (Powershell)
  97. uses: actions/cache@v3
  98. with:
  99. path: |
  100. C:\Users\runneradmin\.conan\data
  101. C:\.conan
  102. C:\Users\runneradmin\.conan\conan_download_cache
  103. key: conan-${{ runner.os }}-${{ runner.arch }}-installer-cache
  104. - name: Create the default Conan profile
  105. run: conan profile new default --detect --force
  106. - name: Get Conan configuration
  107. run: |
  108. conan config install https://github.com/Ultimaker/conan-config.git
  109. conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
  110. - name: Use Conan download cache (Powershell)
  111. run: conan config set storage.download_cache="C:\Users\runneradmin\.conan\conan_download_cache"
  112. - name: Create the Packages (Powershell)
  113. 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"
  114. - name: Upload the Package(s)
  115. if: always()
  116. run: |
  117. conan upload "*" -r cura --all -c
  118. - name: Set Environment variables for Cura (Powershell)
  119. run: |
  120. echo "${Env:WIX}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  121. .\cura_inst\Scripts\activate_github_actions_env.ps1
  122. .\cura_inst\Scripts\activate_github_actions_version_env.ps1
  123. - name: Install OpenSSL shared
  124. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  125. - name: Copy OpenSSL shared (Powershell)
  126. run: |
  127. cp openssl/bin/*.dll ./cura_inst/Scripts/
  128. cp openssl/lib/*.lib ./cura_inst/Lib/
  129. - name: Create the Cura dist
  130. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  131. - name: Output the name file name and extension
  132. id: filename
  133. shell: python
  134. run: |
  135. import os
  136. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  137. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-win64-${{ inputs.architecture }}"
  138. output_env = os.environ["GITHUB_OUTPUT"]
  139. content = ""
  140. if os.path.exists(output_env):
  141. with open(output_env, "r") as f:
  142. content = f.read()
  143. with open(output_env, "w") as f:
  144. f.write(content)
  145. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  146. - name: Summarize the used Conan dependencies
  147. shell: python
  148. run: |
  149. import os
  150. import json
  151. from pathlib import Path
  152. conan_install_info_path = Path("cura_inst/conan_install_info.json")
  153. conan_info = {"installed": []}
  154. if os.path.exists(conan_install_info_path):
  155. with open(conan_install_info_path, "r") as f:
  156. conan_info = json.load(f)
  157. sorted_deps = sorted([dep["recipe"]["id"].replace('#', r' rev: ') for dep in conan_info["installed"]])
  158. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  159. content = ""
  160. if os.path.exists(summary_env):
  161. with open(summary_env, "r") as f:
  162. content = f.read()
  163. with open(summary_env, "w") as f:
  164. f.write(content)
  165. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  166. f.writelines("## Conan packages:\n")
  167. for dep in sorted_deps:
  168. f.writelines(f"`{dep}`\n")
  169. - name: Summarize the used Python modules
  170. shell: python
  171. run: |
  172. import os
  173. import pkg_resources
  174. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  175. content = ""
  176. if os.path.exists(summary_env):
  177. with open(summary_env, "r") as f:
  178. content = f.read()
  179. with open(summary_env, "w") as f:
  180. f.write(content)
  181. f.writelines("## Python modules:\n")
  182. for package in pkg_resources.working_set:
  183. f.writelines(f"`{package.key}/{package.version}`\n")
  184. - name: Create PFX certificate from BASE64_PFX_CONTENT secret
  185. id: create-pfx
  186. env:
  187. PFX_CONTENT: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  188. run: |
  189. $pfxPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "cert.pfx";
  190. $encodedBytes = [System.Convert]::FromBase64String($env:PFX_CONTENT);
  191. Set-Content $pfxPath -Value $encodedBytes -AsByteStream;
  192. echo "PFX_PATH=$pfxPath" >> $env:GITHUB_OUTPUT;
  193. - name: Create the Windows msi installer (Powershell)
  194. run: |
  195. python ..\cura_inst\packaging\msi\create_windows_msi.py ..\cura_inst .\UltiMaker-Cura "${{steps.filename.outputs.INSTALLER_FILENAME }}.msi" "$Env:CURA_APP_NAME"
  196. working-directory: dist
  197. - name: Sign the Windows msi installer (Powershell)
  198. env:
  199. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  200. run: |
  201. & "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.INSTALLER_FILENAME }}.msi"
  202. working-directory: dist
  203. - name: Create the Windows exe installer (Powershell)
  204. run: |
  205. python ..\cura_inst\packaging\NSIS\create_windows_installer.py ../cura_inst . "${{steps.filename.outputs.INSTALLER_FILENAME }}.exe"
  206. working-directory: dist
  207. - name: Sign the Windows exe installer (Powershell)
  208. env:
  209. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  210. run: |
  211. & "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.INSTALLER_FILENAME }}.exe"
  212. working-directory: dist
  213. - name: Upload the msi
  214. uses: actions/upload-artifact@v3
  215. with:
  216. name: ${{steps.filename.outputs.INSTALLER_FILENAME }}-msi
  217. path: |
  218. dist/${{steps.filename.outputs.INSTALLER_FILENAME }}.msi
  219. retention-days: 5
  220. - name: Upload the exe
  221. uses: actions/upload-artifact@v3
  222. with:
  223. name: ${{steps.filename.outputs.INSTALLER_FILENAME }}-exe
  224. path: |
  225. dist/${{steps.filename.outputs.INSTALLER_FILENAME }}.exe
  226. retention-days: 5
  227. # NOTE: The extension is .sh, since this isn't going to build-environment, so not on the Win build image.
  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. # NOTE: The extension is .sh, since this isn't going to build-environment, so not on the Win build image.
  235. - name: Upload the run info
  236. uses: actions/upload-artifact@v3
  237. with:
  238. name: windows-run-info
  239. path: |
  240. run_info.sh
  241. retention-days: 5
  242. notify-export:
  243. if: ${{ always() }}
  244. needs: [ cura-installer-create ]
  245. uses: ultimaker/cura/.github/workflows/notify.yml@main
  246. with:
  247. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  248. success_title: "Create the Cura distributions"
  249. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  250. failure_title: "Failed to create the Cura distributions"
  251. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  252. secrets: inherit