macos.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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 -c tools.build:skip_test=True
  143. - name: Remove internal packages before uploading
  144. run: |
  145. conan remove "*@internal/*" -f || true
  146. conan remove "cura_private_data*" -f || true
  147. - name: Upload the Package(s)
  148. run: |
  149. conan upload "*" -r cura --all -c
  150. - name: Set Environment variables for Cura (bash)
  151. run: |
  152. . ./cura_inst/bin/activate_github_actions_env.sh
  153. . ./cura_inst/bin/activate_github_actions_version_env.sh
  154. - name: Unlock Macos keychain (Bash)
  155. run: security unlock -p $TEMP_KEYCHAIN_PASSWORD signing_temp.keychain
  156. env:
  157. TEMP_KEYCHAIN_PASSWORD: ${{ steps.macos-keychain-developer-cert.outputs.keychain-password }}
  158. # FIXME: This is a workaround to ensure that we use and pack a shared library for OpenSSL 1.1.1l. We currently compile
  159. # OpenSSL statically for CPython, but our Python Dependenies (such as PyQt6) require a shared library.
  160. # Because Conan won't allow for building the same library with two different options (easily) we need to install it explicitly
  161. # and do a manual copy to the VirtualEnv, such that Pyinstaller can find it.
  162. - name: Install OpenSSL shared
  163. run: conan install openssl/1.1.1l@_/_ --build=missing --update -o openssl:shared=True -g deploy
  164. - name: Copy OpenSSL shared (Bash)
  165. run: |
  166. cp ./openssl/lib/*.so* ./cura_inst/bin/ || true
  167. cp ./openssl/lib/*.dylib* ./cura_inst/bin/ || true
  168. - name: Create the Cura dist
  169. run: pyinstaller ./cura_inst/UltiMaker-Cura.spec
  170. - name: Output the name file name and extension
  171. id: filename
  172. shell: python
  173. run: |
  174. import os
  175. enterprise = "-Enterprise" if "${{ inputs.enterprise }}" == "true" else ""
  176. installer_filename = f"UltiMaker-Cura-{os.getenv('CURA_VERSION_FULL')}{enterprise}-macos-${{ inputs.architecture }}"
  177. output_env = os.environ["GITHUB_OUTPUT"]
  178. content = ""
  179. if os.path.exists(output_env):
  180. with open(output_env, "r") as f:
  181. content = f.read()
  182. with open(output_env, "w") as f:
  183. f.write(content)
  184. f.writelines(f"INSTALLER_FILENAME={installer_filename}\n")
  185. - name: Summarize the used dependencies
  186. shell: python
  187. run: |
  188. import os
  189. from cura.CuraVersion import ConanInstalls, PythonInstalls
  190. summary_env = os.environ["GITHUB_STEP_SUMMARY"]
  191. content = ""
  192. if os.path.exists(summary_env):
  193. with open(summary_env, "r") as f:
  194. content = f.read()
  195. with open(summary_env, "w") as f:
  196. f.write(content)
  197. f.writelines("# ${{ steps.filename.outputs.INSTALLER_FILENAME }}\n")
  198. f.writelines("## Conan packages:\n")
  199. for dep_name, dep_info in ConanInstalls.items():
  200. f.writelines(f"`{dep_name} {dep_info['version']} {dep_info['revision']}`\n")
  201. f.writelines("## Python modules:\n")
  202. for dep_name, dep_info in PythonInstalls.items():
  203. f.writelines(f"`{dep_name} {dep_info['version']}`\n")
  204. - name: Create the Macos dmg (Bash)
  205. 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"
  206. working-directory: dist
  207. - name: Upload the dmg
  208. uses: actions/upload-artifact@v3
  209. with:
  210. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-dmg
  211. path: |
  212. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.dmg
  213. retention-days: 5
  214. - name: Upload the pkg
  215. uses: actions/upload-artifact@v3
  216. with:
  217. name: ${{ steps.filename.outputs.INSTALLER_FILENAME }}-pkg
  218. path: |
  219. dist/${{ steps.filename.outputs.INSTALLER_FILENAME }}.pkg
  220. retention-days: 5
  221. - name: Write the run info
  222. shell: python
  223. run: |
  224. import os
  225. with open("run_info.sh", "w") as f:
  226. f.writelines(f'echo "CURA_VERSION_FULL={os.environ["CURA_VERSION_FULL"]}" >> $GITHUB_ENV\n')
  227. - name: Upload the run info
  228. uses: actions/upload-artifact@v3
  229. with:
  230. name: macos-run-info
  231. path: |
  232. run_info.sh
  233. retention-days: 5
  234. notify-export:
  235. if: ${{ always() }}
  236. needs: [ cura-installer-create ]
  237. uses: ultimaker/cura/.github/workflows/notify.yml@main
  238. with:
  239. success: ${{ contains(join(needs.*.result, ','), 'success') }}
  240. success_title: "Create the Cura distributions"
  241. success_body: "Installers for ${{ inputs.cura_conan_version }}"
  242. failure_title: "Failed to create the Cura distributions"
  243. failure_body: "Failed to create at least 1 installer for ${{ inputs.cura_conan_version }}"
  244. secrets: inherit