windows.yml 9.7 KB

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