Browse Source

Revert dmg deprecation

CURA-6867
Joey de l'Arago 2 years ago
parent
commit
05e1f57324

+ 23 - 2
.github/workflows/cura-all-installers.yml

@@ -1,5 +1,5 @@
 name: Cura All Installers
-run-name: ${{ inputs.cura_conan_version }} for exe ${{ inputs.build_windows_exe }}, msi ${{ inputs.build_windows_msi }}, dmg ${{ inputs.build_macos }}, appimage ${{ inputs.build_linux }} - enterprise ${{ inputs.enterprise }}
+run-name: ${{ inputs.cura_conan_version }} for exe ${{ inputs.build_windows_exe }}, msi ${{ inputs.build_windows_msi }}, dmg ${{ inputs.build_macos }}, pkg ${{ inputs.build_macos_installer }}, appimage ${{ inputs.build_linux }} - enterprise ${{ inputs.enterprise }}
 
 on:
     workflow_dispatch:
@@ -50,7 +50,12 @@ on:
                 required: true
                 type: boolean
             build_macos:
-                description: 'Build for MacOS'
+                description: 'Build dmg for MacOS'
+                default: true
+                required: true
+                type: boolean
+            build_macos_installer:
+                description: 'Build pkg for MacOS'
                 default: true
                 required: true
                 type: boolean
@@ -120,6 +125,21 @@ jobs:
             msi_installer: false
         secrets: inherit
 
+    macos-dmg-create:
+        if: ${{ inputs.build_macos }}
+        uses: ./.github/workflows/cura-installer.yml
+        with:
+            platform: 'macos-11'
+            os_name: 'mac'
+            cura_conan_version: ${{ inputs.cura_conan_version }}
+            conan_args: ${{ inputs.conan_args }}
+            conan_config: ${{ inputs.conan_config }}
+            enterprise: ${{ inputs.enterprise }}
+            staging: ${{ inputs.staging }}
+            installer: ${{ inputs.installer }}
+            msi_installer: false
+        secrets: inherit
+
     macos-installer-create:
         if: ${{ inputs.build_macos }}
         uses: ./.github/workflows/cura-installer.yml
@@ -133,4 +153,5 @@ jobs:
             staging: ${{ inputs.staging }}
             installer: ${{ inputs.installer }}
             msi_installer: false
+            pkg_installer: true
         secrets: inherit

+ 8 - 3
.github/workflows/cura-installer.yml

@@ -49,6 +49,11 @@ on:
                 default: false
                 required: true
                 type: boolean
+            pkg_installer:
+                description: 'Create the pkg'
+                default: false
+                required: true
+                type: boolean
 
 env:
     CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
@@ -120,7 +125,7 @@ jobs:
 
             -   name: Install MacOS system requirements
                 if:  ${{ runner.os == 'Macos' }}
-                run: brew install autoconf automake ninja
+                run: brew install autoconf automake ninja create-dmg
 
             -   name: Install Linux system requirements
                 if: ${{ runner.os == 'Linux' }}
@@ -251,7 +256,7 @@ jobs:
                     if "${{ runner.os }}" == "Windows":
                         installer_ext = "msi" if "${{ inputs.msi_installer }}" == "true" else "exe"
                     elif "${{ runner.os }}" == "macOS":
-                        installer_ext = "pkg"
+                        installer_ext = "pkg" if "${{ inputs.pkg_installer }}" == "true" else "dmg"
                     else:
                         installer_ext = "AppImage"
                     output_env = os.environ["GITHUB_OUTPUT"]
@@ -308,7 +313,7 @@ jobs:
                 run: python ../cura_inst/packaging/AppImage/create_appimage.py ./UltiMaker-Cura $CURA_VERSION_FULL "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
                 working-directory: dist
 
-            -   name: Create the MacOS pkg (Bash)
+            -   name: Create the MacOS dmg and/or pkg (Bash)
                 if: ${{ github.event.inputs.installer == 'true' && runner.os == 'Macos' }}
                 run: python ../cura_inst/packaging/MacOS/build_macos.py . "${{ steps.filename.outputs.FULL_INSTALLER_FILENAME }}"
                 working-directory: dist

+ 42 - 1
packaging/MacOS/build_macos.py

@@ -9,6 +9,24 @@ from pathlib import Path
 
 ULTIMAKER_CURA_DOMAIN = os.environ.get("ULTIMAKER_CURA_DOMAIN", "nl.ultimaker.cura")
 
+def build_dmg(source_path: str, dist_path: str, filename: str) -> None:
+    create_dmg_executable = os.environ.get("CREATE_DMG_EXECUTABLE", "create-dmg")
+
+    arguments = [create_dmg_executable,
+                 "--window-pos", "640", "360",
+                 "--window-size", "690", "503",
+                 "--app-drop-link", "520", "272",
+                 "--volicon", f"{source_path}/packaging/icons/VolumeIcons_Cura.icns",
+                 "--icon-size", "90",
+                 "--icon", "UltiMaker-Cura.app", "169", "272",
+                 "--eula", f"{source_path}/packaging/cura_license.txt",
+                 "--background", f"{source_path}/packaging/MacOs/cura_background_dmg.png",
+                 f"{dist_path}/{filename}",
+                 f"{dist_path}/UltiMaker-Cura.app"]
+
+    subprocess.run(arguments)
+
+
 def build_pkg(dist_path: str, app_filename: str, component_filename: str, installer_filename: str) -> None:
     """ Builds and signs the pkg installer.
 
@@ -102,10 +120,33 @@ def create_pkg_installer(filename: str,  dist_path: str) -> None:
     if notarize:
         notarize_file(dist_path, filename)
 
+
+def create_dmg(filename: str, dist_path: str, source_path: str) -> None:
+    """ Creates a dmg executable from UltiMaker-Cura.app named {filename}.dmg
+
+    @param filename: The name of the app file and the output dmg file without the extension
+    @param dist_path: The location to read the app from and save the dmg to
+    @param source_path: The location of the project source files
+    """
+
+    dmg_filename = f"{filename}.dmg"
+
+    build_dmg(source_path, dist_path, dmg_filename)
+
+    notarize_dmg = bool(os.environ.get("NOTARIZE_DMG", "TRUE"))
+    if notarize_dmg:
+        notarize_file(dist_path, dmg_filename)
+
+
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description = "Create installer for Cura.")
     parser.add_argument("dist_path", type = str, help="Path to Pyinstaller dist folder")
     parser.add_argument("filename", type = str, help = "Filename of the pkg (e.g. 'UltiMaker-Cura-5.1.0-beta-Macos-X64.pkg')")
     args = parser.parse_args()
 
-    create_pkg_installer(args.filename, args.dist_path)
+    if Path(args.filename).suffix == ".pkg":
+        create_pkg_installer(args.filename, args.dist_path)
+    elif Path(args.filename).suffix == ".dmg":
+        create_dmg(args.filename, args.dist_path, args.source_path)
+    else:
+        create_dmg(args.filename, args.dist_path, args.source_path)