macos.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. name: Macos Installer
  2. run-name: ${{ inputs.cura_conan_version }} for Macos-${{ 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: 'ARM64'
  30. type: choice
  31. options:
  32. - X64
  33. - ARM64
  34. operating_system:
  35. description: 'OS'
  36. required: true
  37. default: 'self-hosted-ARM64'
  38. type: choice
  39. options:
  40. - self-hosted-X64
  41. - self-hosted-ARM64
  42. - macos-11
  43. - macos-12
  44. workflow_call:
  45. inputs:
  46. cura_conan_version:
  47. description: 'Cura Conan Version'
  48. default: 'cura/latest@ultimaker/testing'
  49. required: true
  50. type: string
  51. conan_args:
  52. description: 'Conan args: eq.: --require-override'
  53. default: ''
  54. required: false
  55. type: string
  56. enterprise:
  57. description: 'Build Cura as an Enterprise edition'
  58. default: false
  59. required: true
  60. type: boolean
  61. staging:
  62. description: 'Use staging API'
  63. default: false
  64. required: true
  65. type: boolean
  66. architecture:
  67. description: 'Architecture'
  68. required: true
  69. default: 'ARM64'
  70. type: string
  71. operating_system:
  72. description: 'OS'
  73. required: true
  74. default: 'self-hosted-ARM64'
  75. type: string
  76. env:
  77. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  78. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  79. CODESIGN_IDENTITY: ${{ secrets.CODESIGN_IDENTITY }}
  80. MAC_NOTARIZE_USER: ${{ secrets.MAC_NOTARIZE_USER }}
  81. MAC_NOTARIZE_PASS: ${{ secrets.MAC_NOTARIZE_PASS }}
  82. MACOS_CERT_P12: ${{ secrets.MACOS_CERT_P12 }}
  83. MACOS_CERT_INSTALLER_P12: ${{ secrets.MACOS_CERT_INSTALLER_P12 }}
  84. MACOS_CERT_USER: ${{ secrets.MACOS_CERT_USER }}
  85. MACOS_CERT_PASSPHRASE: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  86. CURA_CONAN_VERSION: ${{ inputs.cura_conan_version }}
  87. ENTERPRISE: ${{ inputs.enterprise }}
  88. STAGING: ${{ inputs.staging }}
  89. jobs:
  90. cura-installer-create:
  91. runs-on: ${{ inputs.operating_system }}
  92. outputs:
  93. INSTALLER_FILENAME: ${{ steps.filename.outputs.INSTALLER_FILENAME }}
  94. steps:
  95. - name: Checkout
  96. uses: actions/checkout@v3
  97. - name: Setup Python and pip
  98. uses: actions/setup-python@v4
  99. with:
  100. python-version: '3.11.x'
  101. cache: 'pip'
  102. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  103. - name: Install Python requirements for runner
  104. run: pip install -r .github/workflows/requirements-conan-package.txt
  105. - name: Cache Conan local repository packages (Bash)
  106. uses: actions/cache@v3
  107. with:
  108. path: |
  109. $HOME/.conan/data
  110. $HOME/.conan/conan_download_cache
  111. key: conan-${{ runner.os }}-${{ runner.arch }}-installer-cache
  112. - name: Install MacOS system requirements
  113. run: brew install cmake autoconf automake ninja create-dmg
  114. - name: Create the default Conan profile
  115. run: conan profile new default --detect --force
  116. - name: Remove Macos keychain (Bash)
  117. run: security delete-keychain signing_temp.keychain || true
  118. - name: Configure Macos keychain Developer Cert(Bash)
  119. id: macos-keychain-developer-cert
  120. uses: apple-actions/import-codesign-certs@v1
  121. with:
  122. keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  123. p12-file-base64: ${{ secrets.MACOS_CERT_P12 }}
  124. p12-password: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  125. - name: Configure Macos keychain Installer Cert (Bash)
  126. id: macos-keychain-installer-cert
  127. uses: apple-actions/import-codesign-certs@v1
  128. with:
  129. keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  130. create-keychain: false # keychain is created in previous use of action.
  131. p12-file-base64: ${{ secrets.MACOS_CERT_INSTALLER_P12 }}
  132. p12-password: ${{ secrets.MACOS_CERT_PASSPHRASE }}
  133. - name: Remove private Artifactory
  134. run: conan remote remove cura-conan-private || true
  135. - name: Get Conan configuration
  136. run: |
  137. conan config install https://github.com/Ultimaker/conan-config.git
  138. conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
  139. - name: Use Conan download cache (Bash)
  140. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  141. - name: Create the Packages (Bash)
  142. 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"
  143. - name: Upload the Package(s)
  144. if: ${{ inputs.operating_system != 'self-hosted' }}
  145. run: |
  146. conan upload "*" -r cura --all -c
  147. - name: Set Environment variables for Cura (bash)
  148. run: |
  149. . ./cura_inst/bin/activate_github_actions_env.sh
  150. . ./cura_inst/bin/activate_github_actions_version_env.sh
  151. - name: Unlock Macos keychain (Bash)
  152. run: security unlock -p $TEMP_KEYCHAIN_PASSWORD signing_temp.keychain
  153. env:
  154. TEMP_KEYCHAIN_PASSWORD: ${{ steps.macos-keychain-developer-cert.outputs.keychain-password }}
  155. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  156. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  157. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  158. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  159. - name: Install OpenSSL shared
  160. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  161. - name: Copy OpenSSL shared (Bash)
  162. run: |
  163. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  164. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  165. - name: Create the Cura dist
  166. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  167. - name: Output the name file name and extension
  168. id: filename
  169. shell: python
  170. run: |
  171. import os
  172. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  173. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-macos-${{ inputs.architecture }}"
  174. output_env = os.environ["GITHUB_OUTPUT"]
  175. content = ""
  176. if os.path.exists(output_env):
  177. with open(output_env, "r") as f:
  178. content = f.read()
  179. with open(output_env, "w") as f:
  180. f.write(content)
  181. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  182. - name: Summarize the used Conan dependencies
  183. shell: python
  184. run: |
  185. import os
  186. import json
  187. from pathlib import Path
  188. from cura.CuraVersion import ConanInstalls
  189. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  190. content = ""
  191. if os.path.exists(summary_env):
  192. with open(summary_env, "r") as f:
  193. content = f.read()
  194. with open(summary_env, "w") as f:
  195. f.write(content)
  196. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  197. f.writelines("## Conan packages:\n")
  198. for dep_name, dep_info in ConanDependencies.items():
  199. f.writelines(f"`{dep_name} {dep_info["version"]} {dep_info["revision"]}`\n")
  200. - name: Summarize the used Python modules
  201. shell: python
  202. run: |
  203. import os
  204. import pkg_resources
  205. from cura.CuraVersion import PythonInstalls
  206. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  207. content = ""
  208. if os.path.exists(summary_env):
  209. with open(summary_env, "r") as f:
  210. content = f.read()
  211. with open(summary_env, "w") as f:
  212. f.write(content)
  213. f.writelines("## Python modules:\n")
  214. for dep_name, dep_info in ConanDependencies.items():
  215. f.writelines(f"`{dep_name} {dep_info["version"]}`\n")
  216. - name: Create the Macos dmg (Bash)
  217. run: python ../cura_inst/packaging/MacOS/build_macos.py --source_path ../cura_inst --dist_path . --cura_conan_version $CURA_CONAN_VERSION --filename "${{ steps.filename.outputs.INSTALLER_FILENAME }}" --build_dmg --build_pkg --app_name "$CURA_APP_NAME"
  218. working-directory: dist
  219. - name: Upload the dmg
  220. uses: actions/upload-artifact@v3
  221. with:
  222. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-dmg
  223. path: |
  224. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.dmg
  225. retention-days: 5
  226. - name: Upload the pkg
  227. uses: actions/upload-artifact@v3
  228. with:
  229. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-pkg
  230. path: |
  231. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.pkg
  232. retention-days: 5
  233. - name: Write the run info
  234. shell: python
  235. run: |
  236. import os
  237. with open("run_info.sh", "w") as f:
  238. f.writelines(f'echo "CURA_VERSION_FULL={os.environ["CURA_VERSION_FULL"]}" >> $GITHUB_ENV\n')
  239. - name: Upload the run info
  240. uses: actions/upload-artifact@v3
  241. with:
  242. name: macos-run-info
  243. path: |
  244. run_info.sh
  245. retention-days: 5
  246. notify-export:
  247. if: ${{ always() }}
  248. needs: [ cura-installer-create ]
  249. uses: ultimaker/cura/.github/workflows/notify.yml@main
  250. with:
  251. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  252. success_title: "Create the Cura distributions"
  253. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  254. failure_title: "Failed to create the Cura distributions"
  255. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  256. secrets: inherit