Feat: overhaul to produce .dmg and .app on macOS build script

This commit is contained in:
2026-02-28 03:15:51 +01:00
parent 7ae3f255b0
commit 81fb174d7e
6 changed files with 136 additions and 1 deletions

View File

@@ -229,6 +229,14 @@ bundle_plugins_native() {
cargo xtask bundle "$PLUGIN_NAME" --release $tf
}
bundle_desktop_native() {
local platform="$1"
local tf
tf=$(target_flag "$platform")
# shellcheck disable=SC2086
cargo bundle --release --features desktop --bin cagire-desktop $tf
}
bundle_plugins_cross() {
local platform="$1"
local rd
@@ -300,6 +308,18 @@ copy_artifacts() {
local dst="$OUT/cagire-desktop-${os}-${arch}${suffix}"
cp "$src" "$dst"
echo " cagire-desktop -> $dst"
# macOS .app bundle
if [[ "$os" == "macos" ]]; then
local app_src="$rd/bundle/osx/Cagire.app"
if [[ -d "$app_src" ]]; then
local app_dst="$OUT/Cagire-${arch}.app"
rm -rf "$app_dst"
cp -R "$app_src" "$app_dst"
echo " Cagire.app -> $app_dst"
scripts/make-dmg.sh "$app_dst" "$OUT"
fi
fi
fi
# AppImage for Linux targets
@@ -407,6 +427,10 @@ for platform in "${selected_platforms[@]}"; do
if $build_desktop; then
echo " -> cagire-desktop"
build_binary "$platform" --features desktop --bin cagire-desktop
if ! is_cross_target "$platform"; then
echo " -> bundling cagire-desktop .app"
bundle_desktop_native "$platform"
fi
fi
if $build_plugins; then

52
scripts/make-dmg.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -euo pipefail
# Usage: scripts/make-dmg.sh <app-path> <output-dir>
# Produces a .dmg from a macOS .app bundle using only hdiutil.
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <app-path> <output-dir>"
exit 1
fi
APP_PATH="$1"
OUTDIR="$2"
REPO_ROOT="$(git rev-parse --show-toplevel)"
if [[ ! -d "$APP_PATH" ]]; then
echo "ERROR: $APP_PATH is not a directory"
exit 1
fi
LIPO_OUTPUT=$(lipo -info "$APP_PATH/Contents/MacOS/cagire-desktop" 2>/dev/null)
if [[ -z "$LIPO_OUTPUT" ]]; then
echo "ERROR: could not determine architecture from $APP_PATH"
exit 1
fi
if echo "$LIPO_OUTPUT" | grep -q "Architectures in the fat file"; then
ARCH="universal"
else
ARCH=$(echo "$LIPO_OUTPUT" | awk '{print $NF}')
case "$ARCH" in
arm64) ARCH="aarch64" ;;
esac
fi
STAGING="$(mktemp -d)"
trap 'rm -rf "$STAGING"' EXIT
cp -R "$APP_PATH" "$STAGING/Cagire.app"
ln -s /Applications "$STAGING/Applications"
cp "$REPO_ROOT/assets/DMG-README.txt" "$STAGING/README.txt"
DMG_NAME="Cagire-${ARCH}.dmg"
mkdir -p "$OUTDIR"
hdiutil create -volname "Cagire" \
-srcfolder "$STAGING" \
-ov -format UDZO \
"$OUTDIR/$DMG_NAME"
echo " DMG -> $OUTDIR/$DMG_NAME"