Skip to content

alessio/mkdmg

Repository files navigation

💿 mkdmg

The Fancy Apple Disk Image Creator

Go GoDoc Go Report Card License GitHub release (latest SemVer)


mkdmg is a powerful, modern CLI wrapper around hdiutil designed to make creating, signing, and notarizing macOS Disk Images (.dmg) effortless.


✨ Features

  • 🚀 Simple: Create DMGs with a single command.
  • ⚙️ Configurable: JSON configuration for reproducible builds.
  • 📦 Formats: Supports multiple DMG formats (UDZO, UDBZ, ULFO, ULMO).
  • 🔐 Security: Integrated codesigning and notarization workflow.
  • 🖥️ Filesystems: Support for both HFS+ and APFS.
  • 🛡️ Sandbox: Create sandbox-safe disk images.

📦 Installation

Pre-built Binaries

You can download the latest pre-built binaries for macOS (Darwin) from the GitHub Releases page.

  1. Visit the releases page.
  2. Download the archive matching your architecture (x86_64 or arm64).
  3. Extract the archive and move the mkdmg binary to a directory in your PATH (e.g., /usr/local/bin).

From Source

Requires Go 1.26 or later.

go install al.essio.dev/cmd/mkdmg@latest

To build from a local checkout:

make build

Verification

To verify the integrity of the downloaded binary, you can use the checksums.txt file provided in the GitHub Releases.

  1. Download the binary archive and the checksums.txt file.
  2. Run the following command to verify the checksum:
sha256sum -c checksums.txt --ignore-missing

🚀 Usage

mkdmg [OPTION]... [OUTFILE.DMG [DIRECTORY]]

mkdmg reads its configuration from a JSON file (default: mkdmg.json in the current directory). You can optionally provide positional arguments to override the output path and source directory from the config.

# Use default config (mkdmg.json)
mkdmg

# Use a specific config file
mkdmg --config path/to/config.json

# Override output path and source directory
mkdmg MyApp.dmg ./build

# Override output path only (source_dir must be in config)
mkdmg MyApp.dmg

# Dry run to preview commands
mkdmg --dry-run --verbose

⚙️ Options

Flag Shorthand Description Default
--config Path to a JSON configuration file. mkdmg.json
--dry-run -s Simulate the process without creating any files. false
--verbose -v Enable verbose output for mkdmg. false
--version -V Print version information and exit.
--help -h Display the help message and exit.

📄 JSON Configuration

All build settings are defined in the JSON configuration file.

Example mkdmg.json

{
  "volume_name": "MyApplication",
  "volume_size_mb": 0,
  "sandbox_safe": false,
  "bless": false,
  "filesystem": "HFS+",
  "signing_identity": "",
  "notarize_credentials": "",
  "image_format": "UDZO",
  "hdiutil_verbosity": 0,
  "output_path": "./dist/MyApplication.dmg",
  "source_dir": "./build/Release",
  "simulate": false
}

Configuration Reference

Field Type Default Description
volume_name string (Filename) Name of the mounted volume. Defaults to output_path filename if empty.
volume_size_mb number 0 Volume size in megabytes. If 0, hdiutil calculates the minimum size automatically.
sandbox_safe boolean false Enables sandbox-safe mode. Incompatible with APFS.
bless boolean false Blesses the folder/volume (makes it bootable/auto-open).
filesystem string "HFS+" Filesystem type. Options: "HFS+", "APFS".
signing_identity string "" Name or hash of the code signing identity to use.
notarize_credentials string "" Profile name for notarytool credentials.
image_format string "UDZO" DMG format. Options: "UDZO" (zlib), "UDBZ" (bzip2), "ULFO" (lzfse), "ULMO" (lzma).
hdiutil_verbosity number 0 Verbosity level for the underlying hdiutil command.
output_path string (Required) Destination path for the .dmg file.
source_dir string (Required) Directory containing files to package.
simulate boolean false If true, prints commands without executing them.

Made with ❤️ by Alessio Treglia