macos.yml 11 KB

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