diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fce403a5..b4cb9c9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,16 +92,32 @@ jobs: target/x86_64-apple-darwin/release/psst-gui \ target/aarch64-apple-darwin/release/psst-gui - - name: Create macOS Disk Image + - name: Install create-dmg if: runner.os == 'macOS' - run: hdiutil create -volname "Psst" -srcfolder target/release/bundle/osx -ov -format UDZO Psst.dmg + run: brew install create-dmg - - name: Upload macOS Disk Image + - name: Create DMG + if: runner.os == 'macOS' + run: | + create-dmg \ + --volname "Psst" \ + --volicon "psst-gui/assets/logo.icns" \ + --window-pos 200 120 \ + --window-size 600 400 \ + --icon-size 100 \ + --icon "Psst.app" 150 160 \ + --hide-extension "Psst.app" \ + --app-drop-link 450 160 \ + --no-internet-enable \ + "Psst.dmg" \ + "target/release/bundle/osx/Psst.app" + + - name: Upload macOS DMG uses: actions/upload-artifact@v4 if: runner.os == 'macOS' with: name: Psst.dmg - path: ./Psst.dmg + path: Psst.dmg - name: Make Linux Binary Executable if: runner.os == 'Linux' diff --git a/psst-gui/Cargo.toml b/psst-gui/Cargo.toml index b7a42fdb..a0401614 100644 --- a/psst-gui/Cargo.toml +++ b/psst-gui/Cargo.toml @@ -60,13 +60,7 @@ image = { version = "0.25.1" } [package.metadata.bundle] name = "Psst" identifier = "com.jpochyla.psst" -icon = [ - "assets/logo_32.png", - "assets/logo_64.png", - "assets/logo_128.png", - "assets/logo_256.png", - "assets/logo_512.png", -] +icon = ["assets/logo.icns"] version = "0.1.0" resources = [] copyright = "Copyright (c) Jan Pochyla 2024. All rights reserved." diff --git a/psst-gui/assets/logo.icns b/psst-gui/assets/logo.icns new file mode 100644 index 00000000..547a8588 Binary files /dev/null and b/psst-gui/assets/logo.icns differ diff --git a/psst-gui/build-icons.sh b/psst-gui/build-icons.sh new file mode 100755 index 00000000..9ae4754e --- /dev/null +++ b/psst-gui/build-icons.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -euo pipefail + +# Check for required tools +command -v rsvg-convert >/dev/null 2>&1 || { + echo >&2 "rsvg-convert is required but not installed. Aborting." + exit 1 +} +command -v iconutil >/dev/null 2>&1 || { + echo >&2 "iconutil is required but not installed. Aborting." + exit 1 +} +command -v pngquant >/dev/null 2>&1 || { + echo >&2 "pngquant is required but not installed. Aborting." + exit 1 +} +command -v optipng >/dev/null 2>&1 || { + echo >&2 "optipng is required but not installed. Aborting." + exit 1 +} + +# Temp folder +ICON_DIR="icons" +mkdir -p "$ICON_DIR" + +# Generate PNG icons from SVG +SIZES=(16 32 64 128 256 512) +for size in "${SIZES[@]}"; do + rsvg-convert -w $size -h $size assets/logo.svg -o "$ICON_DIR/logo_${size}.png" + + # Apply lossy compression with pngquant + pngquant --force --quality=60-80 "$ICON_DIR/logo_${size}.png" --output "$ICON_DIR/logo_${size}.png" + + # Further optimize with optipng + optipng -quiet -o5 "$ICON_DIR/logo_${size}.png" + + # For smaller sizes, reduce color depth + if [ $size -le 32 ]; then + magick "$ICON_DIR/logo_${size}.png" -colors 256 PNG8:"$ICON_DIR/logo_${size}.png" + fi +done + +# Generate ICNS for macOS +ICONSET_DIR="$ICON_DIR/psst.iconset" +mkdir -p "$ICONSET_DIR" +for size in "${SIZES[@]}"; do + cp "$ICON_DIR/logo_${size}.png" "$ICONSET_DIR/icon_${size}x${size}.png" + if [ $size -ne 16 ] && [ $size -ne 32 ]; then + cp "$ICON_DIR/logo_${size}.png" "$ICONSET_DIR/icon_$((size / 2))x$((size / 2))@2x.png" + fi +done + +# Create ICNS file +iconutil -c icns "$ICONSET_DIR" -o assets/logo.icns + +# Cleanup +rm -r "$ICON_DIR" + +echo "Icon generation complete. ICNS file size: $(du -h assets/logo.icns | cut -f1)"