windows.yml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 -c tools.build:skip_test=True
  114. - name: Remove internal packages before uploading
  115. run: |
  116. conan remove "*@internal/*" -f || true
  117. conan remove "cura_private_data*" -f || true
  118. - name: Upload the Package(s)
  119. if: always()
  120. run: |
  121. conan upload "*" -r cura --all -c
  122. - name: Set Environment variables for Cura (Powershell)
  123. run: |
  124. echo "${Env:WIX}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  125. .\cura_inst\Scripts\activate_github_actions_env.ps1
  126. .\cura_inst\Scripts\activate_github_actions_version_env.ps1
  127. - name: Install OpenSSL shared
  128. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  129. - name: Copy OpenSSL shared (Powershell)
  130. run: |
  131. cp openssl/bin/*.dll ./cura_inst/Scripts/
  132. cp openssl/lib/*.lib ./cura_inst/Lib/
  133. - name: Create the Cura dist
  134. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  135. - name: Output the name file name and extension
  136. id: filename
  137. shell: python
  138. run: |
  139. import os
  140. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  141. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-win64-${{ inputs.architecture }}"
  142. output_env = os.environ["GITHUB_OUTPUT"]
  143. content = ""
  144. if os.path.exists(output_env):
  145. with open(output_env, "r") as f:
  146. content = f.read()
  147. with open(output_env, "w") as f:
  148. f.write(content)
  149. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  150. - name: Summarize the used dependencies
  151. shell: python
  152. run: |
  153. import os
  154. from cura.CuraVersion import ConanInstalls, PythonInstalls
  155. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  156. content = ""
  157. if os.path.exists(summary_env):
  158. with open(summary_env, "r") as f:
  159. content = f.read()
  160. with open(summary_env, "w") as f:
  161. f.write(content)
  162. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  163. f.writelines("## Conan packages:\n")
  164. for dep_name, dep_info in ConanInstalls.items():
  165. f.writelines(f"`{dep_name} {dep_info['version']} {dep_info['revision']}`\n")
  166. f.writelines("## Python modules:\n")
  167. for dep_name, dep_info in PythonInstalls.items():
  168. f.writelines(f"`{dep_name} {dep_info['version']}`\n")
  169. - name: Create PFX certificate from BASE64_PFX_CONTENT secret
  170. id: create-pfx
  171. env:
  172. PFX_CONTENT: ${{ secrets.WIN_CERT_INSTALLER_CER }}
  173. run: |
  174. $pfxPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "cert.pfx";
  175. $encodedBytes = [System.Convert]::FromBase64String($env:PFX_CONTENT);
  176. Set-Content $pfxPath -Value $encodedBytes -AsByteStream;
  177. echo "PFX_PATH=$pfxPath" >> $env:GITHUB_OUTPUT;
  178. - name: Create the Windows msi installer (Powershell)
  179. run: |
  180. python ..\cura_inst\packaging\msi\create_windows_msi.py ..\cura_inst .\UltiMaker-Cura "${{steps.filename.outputs.INSTALLER_FILENAME }}.msi" "$Env:CURA_APP_NAME"
  181. working-directory: dist
  182. - name: Sign the Windows msi installer (Powershell)
  183. env:
  184. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  185. run: |
  186. & "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"
  187. working-directory: dist
  188. - name: Create the Windows exe installer (Powershell)
  189. run: |
  190. python ..\cura_inst\packaging\NSIS\create_windows_installer.py ../cura_inst . "${{steps.filename.outputs.INSTALLER_FILENAME }}.exe"
  191. working-directory: dist
  192. - name: Sign the Windows exe installer (Powershell)
  193. env:
  194. PFX_PATH: ${{ steps.create-pfx.outputs.PFX_PATH }}
  195. run: |
  196. & "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"
  197. working-directory: dist
  198. - name: Upload the msi
  199. uses: actions/upload-artifact@v3
  200. with:
  201. name: ${{steps.filename.outputs.INSTALLER_FILENAME }}-msi
  202. path: |
  203. dist/${{steps.filename.outputs.INSTALLER_FILENAME }}.msi
  204. retention-days: 5
  205. - name: Upload the exe
  206. uses: actions/upload-artifact@v3
  207. with:
  208. name: ${{steps.filename.outputs.INSTALLER_FILENAME }}-exe
  209. path: |
  210. dist/${{steps.filename.outputs.INSTALLER_FILENAME }}.exe
  211. retention-days: 5
  212. # NOTE: The extension is .sh, since this isn't going to build-environment, so not on the Win build image.
  213. - name: Write the run info
  214. shell: python
  215. run: |
  216. import os
  217. with open("run_info.sh", "w") as f:
  218. f.writelines(f'echo "CURA_VERSION_FULL={os.environ["CURA_VERSION_FULL"]}" >> $GITHUB_ENV\n')
  219. # NOTE: The extension is .sh, since this isn't going to build-environment, so not on the Win build image.
  220. - name: Upload the run info
  221. uses: actions/upload-artifact@v3
  222. with:
  223. name: windows-run-info
  224. path: |
  225. run_info.sh
  226. retention-days: 5
  227. notify-export:
  228. if: ${{ always() }}
  229. needs: [ cura-installer-create ]
  230. uses: ultimaker/cura/.github/workflows/notify.yml@main
  231. with:
  232. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  233. success_title: "Create the Cura distributions"
  234. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  235. failure_title: "Failed to create the Cura distributions"
  236. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  237. secrets: inherit