windows.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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
  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. from cura.CuraVersion import ConanInstalls
  153. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  154. content = ""
  155. if os.path.exists(summary_env):
  156. with open(summary_env, "r") as f:
  157. content = f.read()
  158. with open(summary_env, "w") as f:
  159. f.write(content)
  160. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  161. f.writelines("## Conan packages:\n")
  162. for dep_name, dep_info in ConanDependencies.items():
  163. f.writelines(f"`{dep_name} {dep_info["version"]} {dep_info["revision"]}`\n")
  164. - name: Summarize the used Python modules
  165. shell: python
  166. run: |
  167. import os
  168. import pkg_resources
  169. from cura.CuraVersion import PythonInstalls
  170. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  171. content = ""
  172. if os.path.exists(summary_env):
  173. with open(summary_env, "r") as f:
  174. content = f.read()
  175. with open(summary_env, "w") as f:
  176. f.write(content)
  177. f.writelines("## Python modules:\n")
  178. for dep_name, dep_info in ConanDependencies.items():
  179. f.writelines(f"`{dep_name} {dep_info["version"]}`\n")
  180. - name: Create PFX certificate from BASE64_PFX_CONTENT secret
  181. id: create-pfx
  182. env:
  183. PFX_CONTENT: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  184. run: |
  185. $pfxPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "cert.pfx";
  186. $encodedBytes = [System.Convert]::FromBase64String($env:PFX_CONTENT);
  187. Set-Content $pfxPath -Value $encodedBytes -AsByteStream;
  188. echo "PFX_PATH=$pfxPath" >> $env:GITHUB_OUTPUT;
  189. - name: Create the Windows msi installer (Powershell)
  190. run: |
  191. python ..\cura_inst\packaging\msi\create_windows_msi.py ..\cura_inst .\UltiMaker-Cura "${{steps.filename.outputs.INSTALLER_FILENAME }}.msi" "$Env:CURA_APP_NAME"
  192. working-directory: dist
  193. - name: Sign the Windows msi installer (Powershell)
  194. env:
  195. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  196. run: |
  197. & "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"
  198. working-directory: dist
  199. - name: Create the Windows exe installer (Powershell)
  200. run: |
  201. python ..\cura_inst\packaging\NSIS\create_windows_installer.py ../cura_inst . "${{steps.filename.outputs.INSTALLER_FILENAME }}.exe"
  202. working-directory: dist
  203. - name: Sign the Windows exe installer (Powershell)
  204. env:
  205. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  206. run: |
  207. & "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"
  208. working-directory: dist
  209. - name: Upload the msi
  210. uses: actions/upload-artifact@v3
  211. with:
  212. name: ${{steps.filename.outputs.INSTALLER_FILENAME }}-msi
  213. path: |
  214. dist/${{steps.filename.outputs.INSTALLER_FILENAME }}.msi
  215. retention-days: 5
  216. - name: Upload the exe
  217. uses: actions/upload-artifact@v3
  218. with:
  219. name: ${{steps.filename.outputs.INSTALLER_FILENAME }}-exe
  220. path: |
  221. dist/${{steps.filename.outputs.INSTALLER_FILENAME }}.exe
  222. retention-days: 5
  223. # NOTE: The extension is .sh, since this isn't going to build-environment, so not on the Win build image.
  224. - name: Write the run info
  225. shell: python
  226. run: |
  227. import os
  228. with open("run_info.sh", "w") as f:
  229. f.writelines(f'echo "CURA_VERSION_FULL={os.environ["CURA_VERSION_FULL"]}" >> $GITHUB_ENV\n')
  230. # NOTE: The extension is .sh, since this isn't going to build-environment, so not on the Win build image.
  231. - name: Upload the run info
  232. uses: actions/upload-artifact@v3
  233. with:
  234. name: windows-run-info
  235. path: |
  236. run_info.sh
  237. retention-days: 5
  238. notify-export:
  239. if: ${{ always() }}
  240. needs: [ cura-installer-create ]
  241. uses: ultimaker/cura/.github/workflows/notify.yml@main
  242. with:
  243. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  244. success_title: "Create the Cura distributions"
  245. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  246. failure_title: "Failed to create the Cura distributions"
  247. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  248. secrets: inherit