From 13ef5dc2d3d9f429dd9be671950f6cb4ec75bdd8 Mon Sep 17 00:00:00 2001 From: databandit <8215071+5739n4@users.noreply.github.com> Date: Fri, 1 May 2026 09:15:01 -0400 Subject: [PATCH] create_dmg.sh: fail on stale app version before packaging --- create_dmg.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/create_dmg.sh b/create_dmg.sh index 078c413..7633d45 100755 --- a/create_dmg.sh +++ b/create_dmg.sh @@ -4,6 +4,7 @@ set -e APP_NAME="RuSwitcher" # Единый источник версии — version.json в корне репозитория. VERSION=$(/usr/bin/python3 -c "import json;print(json.load(open('version.json'))['version'])") +BUILD_VERSION=$(/usr/bin/python3 -c "import json;print(json.load(open('version.json')).get('build','1'))") DMG_NAME="${APP_NAME}-${VERSION}.dmg" # Keychain profile used for Apple notarization. Override with NOTARIZE_PROFILE=. # Skip notarization entirely with SKIP_NOTARIZE=1. @@ -16,6 +17,28 @@ DMG_SIZE="10m" echo "=== Creating styled DMG ===" +if [ ! -d "$APP_PATH" ]; then + echo "ERROR: $APP_PATH not found. Build the app first: ./build_app.sh" + exit 1 +fi + +APP_INFO_PLIST="$APP_PATH/Contents/Info.plist" +if [ ! -f "$APP_INFO_PLIST" ]; then + echo "ERROR: $APP_INFO_PLIST not found" + exit 1 +fi + +APP_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$APP_INFO_PLIST" 2>/dev/null || true) +APP_BUILD=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$APP_INFO_PLIST" 2>/dev/null || true) + +if [ "$APP_VERSION" != "$VERSION" ] || [ "$APP_BUILD" != "$BUILD_VERSION" ]; then + echo "ERROR: App bundle version mismatch." + echo " version.json expects: $VERSION (build $BUILD_VERSION)" + echo " $APP_PATH contains: ${APP_VERSION:-?} (build ${APP_BUILD:-?})" + echo "Rebuild app before packaging: ./build_app.sh" + exit 1 +fi + # Clean up rm -f "$DMG_NAME" "$DMG_TEMP"