- fix updater.sh for macOS Mojave (10.14)

- fix notification that new version installed (not showing only if the new version is higher than previous one)

- small fix
This commit is contained in:
Serhiy Mytrovtsiy
2020-07-09 19:03:49 +02:00
parent 533770c761
commit 8296acb5e9
7 changed files with 41 additions and 39 deletions

View File

@@ -95,7 +95,7 @@ prepare-dSYM:
clean:
rm -rf $(BUILD_PATH)
if [ -a $(PWD)/dSYM.zip ]; then rm $(PWD)/dSYM.zip; fi;
if [ -a $(PWD)/dSYMs.zip ]; then rm $(PWD)/dSYMs.zip; fi;
if [ -a $(PWD)/Stats.dmg ]; then rm $(PWD)/Stats.dmg; fi;
next-version:

View File

@@ -1695,7 +1695,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 2.1.8;
MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1727,7 +1727,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 2.1.8;
MARKETING_VERSION = 2.1.9;
PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@@ -100,14 +100,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
return
}
let notification = NSUserNotification()
notification.identifier = UUID().uuidString
notification.title = "Successfully updated"
notification.subtitle = "Stats was updated to the latest version"
notification.soundName = NSUserNotificationDefaultSoundName
notification.hasActionButton = false
NSUserNotificationCenter.default.deliver(notification)
if IsNewestVersion(currentVersion: prevVersion, latestVersion: currentVersion) {
let notification = NSUserNotification()
notification.identifier = UUID().uuidString
notification.title = "Successfully updated"
notification.subtitle = "Stats was updated to the v\(currentVersion)"
notification.soundName = NSUserNotificationDefaultSoundName
notification.hasActionButton = false
NSUserNotificationCenter.default.deliver(notification)
}
os_log(.info, log: log, "Detected previous version %s. Current version (%s) set", prevVersion, currentVersion)
}

View File

@@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>11</string>
<string>14</string>
<key>Description</key>
<string>Simple macOS system monitor in your menu bar</string>
<key>LSApplicationCategoryType</key>

View File

@@ -713,3 +713,28 @@ public func colorFromString(_ colorString: String) -> NSColor {
return NSColor.controlAccentColor
}
}
public func IsNewestVersion(currentVersion: String, latestVersion: String) -> Bool {
let currentNumber = currentVersion.replacingOccurrences(of: "v", with: "")
let latestNumber = latestVersion.replacingOccurrences(of: "v", with: "")
let currentArray = currentNumber.condenseWhitespace().split(separator: ".")
let latestArray = latestNumber.condenseWhitespace().split(separator: ".")
let current = Version(major: Int(currentArray[0]) ?? 0, minor: Int(currentArray[1]) ?? 0, patch: Int(currentArray[2]) ?? 0)
let latest = Version(major: Int(latestArray[0]) ?? 0, minor: Int(latestArray[1]) ?? 0, patch: Int(latestArray[2]) ?? 0)
if latest.major > current.major {
return true
}
if latest.minor > current.minor && latest.major >= current.major {
return true
}
if latest.patch > current.patch && latest.minor >= current.minor && latest.major >= current.major {
return true
}
return false
}

View File

@@ -31,7 +31,7 @@ if [[ "$STEP" == "1" ]]; then
/usr/bin/hdiutil attach "$DMG_PATH" -mountpoint "$MOUNT_PATH" -noverify -nobrowse -noautoopen
cp $MOUNT_PATH/Stats.app/Contents/Resources/Scripts/updater.sh $TMPDIR/updater.sh
sh $TMPDIR/updater.sh --step 2 --app "$CURRENT_PATH" --dmg "$DMG_PATH" &
sh $TMPDIR/updater.sh --step 2 --app "$CURRENT_PATH" --dmg "$DMG_PATH" >/dev/null &
kill -9 $PID

View File

@@ -60,7 +60,7 @@ public class macAppUpdater {
let downloadURL: String = result![1]
let lastVersion: String = result![0]
let newVersion: Bool = self.checkIfNewer(currentVersion: self.currentVersion, latestVersion: lastVersion)
let newVersion: Bool = IsNewestVersion(currentVersion: self.currentVersion, latestVersion: lastVersion)
completionHandler(version(current: self.currentVersion, latest: lastVersion, newest: newVersion, url: downloadURL), nil)
}
@@ -93,31 +93,6 @@ public class macAppUpdater {
task.resume()
}
private func checkIfNewer(currentVersion: String, latestVersion: String) -> Bool {
let currentNumber = currentVersion.replacingOccurrences(of: "v", with: "")
let latestNumber = latestVersion.replacingOccurrences(of: "v", with: "")
let currentArray = currentNumber.condenseWhitespace().split(separator: ".")
let latestArray = latestNumber.condenseWhitespace().split(separator: ".")
let current = Version(major: Int(currentArray[0]) ?? 0, minor: Int(currentArray[1]) ?? 0, patch: Int(currentArray[2]) ?? 0)
let latest = Version(major: Int(latestArray[0]) ?? 0, minor: Int(latestArray[1]) ?? 0, patch: Int(latestArray[2]) ?? 0)
if latest.major > current.major {
return true
}
if latest.minor > current.minor && latest.major >= current.major {
return true
}
if latest.patch > current.patch && latest.minor >= current.minor && latest.major >= current.major {
return true
}
return false
}
public func download(_ url: URL) {
let downloadTask = URLSession.shared.downloadTask(with: url) {
urlOrNil, responseOrNil, errorOrNil in