Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ Package.resolved
# Built app bundle
VocaMac.app/

# DMG build artifacts
*.dmg
dmg-staging*/
# Distribution artifacts
dist/

# Legacy stubs
Sources/CWhisper/
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# VocaMac — Makefile
# Run `make help` for available commands.

.PHONY: build install install-cli test clean run help
.PHONY: build install install-cli dmg test clean run help

## Build .app bundle in repo root (fast, for development)
build:
Expand All @@ -15,6 +15,10 @@ install:
install-cli:
@./scripts/install.sh --cli

## Build DMG for distribution
dmg:
@./scripts/dist.sh

## Run tests
test:
@swift test
Expand All @@ -25,6 +29,7 @@ clean:
@swift package clean
@rm -rf VocaMac.app
@rm -rf .build
@rm -rf dist
@echo "✅ Clean complete"

## Launch the locally built .app (build first with `make build`)
Expand All @@ -38,6 +43,7 @@ help:
@echo " make build Build .app bundle (fast, for development)"
@echo " make install Build + install to /Applications (recommended)"
@echo " make install-cli Install CLI commands to ~/.local/bin"
@echo " make dmg Build DMG for distribution (output in dist/)"
@echo " make test Run tests"
@echo " make run Launch the locally built .app"
@echo " make clean Remove build artifacts"
Expand Down
63 changes: 63 additions & 0 deletions scripts/dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# dist.sh — Build VocaMac and package as a DMG
# Usage: ./scripts/dist.sh
#
# This script:
# 1. Builds VocaMac.app via build.sh
# 2. Creates a DMG with the app and an Applications symlink
# 3. Outputs the DMG to dist/
#
# All artifacts are placed in dist/ — a single, clean output directory.

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"

# Get version from build.sh's Info.plist template
VERSION=$(grep -A1 'CFBundleShortVersionString' scripts/build.sh | grep '<string>' | sed 's/.*<string>\(.*\)<\/string>/\1/' | head -1)
ARCH=$(uname -m)
DMG_NAME="VocaMac-${VERSION}-${ARCH}.dmg"
DIST_DIR="dist"
STAGING_DIR="${DIST_DIR}/.staging"

# Build the app first
echo "🔨 Building VocaMac..."
"$SCRIPT_DIR/build.sh" release

if [ ! -d "VocaMac.app" ]; then
echo "❌ VocaMac.app not found. Build failed."
exit 1
fi

# Clean and prepare dist directory
echo "📦 Preparing distribution..."
rm -rf "$STAGING_DIR"
mkdir -p "$STAGING_DIR"
mkdir -p "$DIST_DIR"

# Stage the app and Applications symlink
cp -R VocaMac.app "$STAGING_DIR/"
ln -sf /Applications "$STAGING_DIR/Applications"

# Create the DMG
echo "💿 Creating DMG..."
hdiutil create -volname "VocaMac" \
-srcfolder "$STAGING_DIR" \
-ov -format UDZO \
"${DIST_DIR}/${DMG_NAME}"

# Clean up staging
rm -rf "$STAGING_DIR"

echo ""
echo "✅ DMG created!"
echo ""
echo " File: ${DIST_DIR}/${DMG_NAME}"
echo " Size: $(du -h "${DIST_DIR}/${DMG_NAME}" | cut -f1)"
echo ""
echo " SHA-256:"
echo " $(shasum -a 256 "${DIST_DIR}/${DMG_NAME}")"
echo ""
echo "🚀 To test: open ${DIST_DIR}/${DMG_NAME}"