-
Notifications
You must be signed in to change notification settings - Fork 140
Package the macOS release as Ludusavi.app #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mtkennerly
merged 3 commits into
mtkennerly:master
from
marcodallagatta:pr/macos-app-bundle
Aug 16, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env python3 | ||
| """Generate a padded macOS ICNS file from Ludusavi's SVG icon.""" | ||
|
|
||
| import argparse | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| CANVAS_SIZE = 1024 | ||
| ART_SIZE = 820 | ||
| ICON_SIZES = [(16, 16), (32, 32), (64, 64), (128, 128), (256, 256), (512, 512), (1024, 1024)] | ||
|
|
||
|
|
||
| def parse_args() -> argparse.Namespace: | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument("input", type=Path, help="source SVG file") | ||
| parser.add_argument("output", type=Path, help="output ICNS file") | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| def main() -> None: | ||
| args = parse_args() | ||
|
|
||
| if shutil.which("rsvg-convert") is None: | ||
| sys.exit("rsvg-convert is required; install librsvg before generating the macOS icon") | ||
|
|
||
| try: | ||
| from PIL import Image | ||
| except ImportError: | ||
| sys.exit("Pillow is required; install it with: python3 -m pip install pillow") | ||
|
|
||
| args.output.parent.mkdir(parents=True, exist_ok=True) | ||
| with tempfile.TemporaryDirectory() as temp_dir: | ||
| raster = Path(temp_dir) / "icon.png" | ||
| subprocess.run( | ||
| [ | ||
| "rsvg-convert", | ||
| "--width", | ||
| str(CANVAS_SIZE), | ||
| "--height", | ||
| str(CANVAS_SIZE), | ||
| str(args.input), | ||
| "--output", | ||
| str(raster), | ||
| ], | ||
| check=True, | ||
| ) | ||
|
|
||
| art = Image.open(raster).convert("RGBA") | ||
| art.thumbnail((ART_SIZE, ART_SIZE), Image.Resampling.LANCZOS) | ||
| canvas = Image.new("RGBA", (CANVAS_SIZE, CANVAS_SIZE), (0, 0, 0, 0)) | ||
| canvas.alpha_composite(art, ((CANVAS_SIZE - art.width) // 2, (CANVAS_SIZE - art.height) // 2)) | ||
| canvas.save(args.output, format="ICNS", sizes=ICON_SIZES) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| if [ "$#" -ne 4 ]; then | ||
| echo "Usage: $0 <binary> <version> <staging-dir> <archive>" >&2 | ||
| exit 64 | ||
| fi | ||
|
|
||
| binary=$1 | ||
| version=$2 | ||
| staging_dir=$3 | ||
| archive=$4 | ||
| repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
| app="$staging_dir/Ludusavi.app" | ||
|
|
||
| test -x "$binary" | ||
| test -f "$repo_root/assets/icon.icns" | ||
|
|
||
| rm -rf "$staging_dir" | ||
| mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" | ||
| cp "$binary" "$app/Contents/MacOS/Ludusavi" | ||
| cp "$repo_root/assets/icon.icns" "$app/Contents/Resources/Ludusavi.icns" | ||
| ln -s "Ludusavi.app/Contents/MacOS/Ludusavi" "$staging_dir/ludusavi" | ||
|
|
||
| cat > "$app/Contents/Info.plist" <<PLIST | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleDisplayName</key> | ||
| <string>Ludusavi</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>Ludusavi</string> | ||
| <key>CFBundleIconFile</key> | ||
| <string>Ludusavi.icns</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>com.mtkennerly.ludusavi</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>Ludusavi</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>APPL</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>${version}</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>${version}</string> | ||
| <key>NSHighResolutionCapable</key> | ||
| <true/> | ||
| </dict> | ||
| </plist> | ||
| PLIST | ||
|
|
||
| tar --create --gzip --file="$archive" --directory="$staging_dir" Ludusavi.app ludusavi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
| temp_dir=$(mktemp -d) | ||
| trap 'rm -rf "$temp_dir"' EXIT | ||
|
|
||
| output="$temp_dir/icon.icns" | ||
|
|
||
| python3 "$repo_root/scripts/generate-macos-icon.py" "$repo_root/assets/icon.svg" "$output" | ||
|
|
||
| test -f "$output" | ||
| /usr/bin/file "$output" | /usr/bin/grep -F 'Mac OS X icon' | ||
|
|
||
| iconset="$temp_dir/icon.iconset" | ||
| /usr/bin/iconutil -c iconset -o "$iconset" "$output" | ||
| test -f "$iconset/icon_512x512@2x.png" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
| temp_dir=$(mktemp -d) | ||
| trap 'rm -rf "$temp_dir"' EXIT | ||
|
|
||
| fixture_binary="$temp_dir/ludusavi" | ||
| printf '#!/usr/bin/env bash\nprintf "fixture\\n"\n' > "$fixture_binary" | ||
| chmod +x "$fixture_binary" | ||
|
|
||
| staging_dir="$temp_dir/staging" | ||
| archive="$temp_dir/ludusavi-v1.2.3-mac.tar.gz" | ||
|
|
||
| "$repo_root/scripts/package-macos-app.sh" "$fixture_binary" 1.2.3 "$staging_dir" "$archive" | ||
|
|
||
| app="$staging_dir/Ludusavi.app" | ||
| plist="$app/Contents/Info.plist" | ||
|
|
||
| test -x "$app/Contents/MacOS/Ludusavi" | ||
| test -f "$app/Contents/Resources/Ludusavi.icns" | ||
| test -L "$staging_dir/ludusavi" | ||
| test "$(readlink "$staging_dir/ludusavi")" = "Ludusavi.app/Contents/MacOS/Ludusavi" | ||
| test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$plist")" = "Ludusavi" | ||
| test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$plist")" = "com.mtkennerly.ludusavi" | ||
| test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist")" = "1.2.3" | ||
| test "$(tar --list --gzip --file="$archive" | /usr/bin/grep -x 'Ludusavi.app/Contents/MacOS/Ludusavi')" = "Ludusavi.app/Contents/MacOS/Ludusavi" | ||
| test "$(tar --list --gzip --file="$archive" | /usr/bin/grep -x 'ludusavi')" = "ludusavi" | ||
|
|
||
| extracted_dir="$temp_dir/extracted" | ||
| mkdir "$extracted_dir" | ||
| tar --extract --gzip --file="$archive" --directory="$extracted_dir" | ||
| test -L "$extracted_dir/ludusavi" | ||
| test "$(readlink "$extracted_dir/ludusavi")" = "Ludusavi.app/Contents/MacOS/Ludusavi" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, how was this
icnsfile generated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I generated it from Ludusavi’s existing assets/icon.svg: rendered it to a 1024×1024 PNG with rsvg-convert, placed it on a transparent 1024×1024 canvas at 820×820 to give it more standard Dock padding (as it looked very big otherwise, compared to the other icons on the dock), then used Pillow to write the .icns sizes from 16 through 1024 pixels. I can add a small reproducible generation script or document the exact command rather than keeping the binary asset as a hand-generated export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a reproducible script would be great if it's not too much hassle 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)