diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24a2a4f..a2bd64a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -198,10 +198,16 @@ jobs: run: | VERSION="${GITHUB_REF_NAME#v}" DMG="Distribution/Insomnia-${VERSION}.dmg" + DMG_ROOT="${RUNNER_TEMP}/insomnia-dmg" + + rm -rf "${DMG_ROOT}" + mkdir -p "${DMG_ROOT}" + ditto Distribution/Insomnia.app "${DMG_ROOT}/Insomnia.app" + ln -s /Applications "${DMG_ROOT}/Applications" hdiutil create \ -volname "Insomnia" \ - -srcfolder Distribution/Insomnia.app \ + -srcfolder "${DMG_ROOT}" \ -ov \ -format UDZO \ "${DMG}" diff --git a/Sources/Insomnia/Update/UpdateChecker.swift b/Sources/Insomnia/Update/UpdateChecker.swift index 3e0574c..53bf643 100644 --- a/Sources/Insomnia/Update/UpdateChecker.swift +++ b/Sources/Insomnia/Update/UpdateChecker.swift @@ -151,14 +151,15 @@ final class UpdateChecker { } } - // MARK: - Download and Install + // MARK: - Download Update /// Downloads the latest DMG and opens it for the user to install. /// /// The DMG is saved to `~/Downloads` and automatically mounted /// via `NSWorkspace` so the user can drag the app to Applications. /// File I/O is performed off the main thread to avoid UI jank. - func downloadAndInstall() async { + @MainActor + func downloadAndOpenInstaller() async { guard let url = downloadURL else { lastError = "No download URL available" return diff --git a/Sources/Insomnia/Views/MenuBarView.swift b/Sources/Insomnia/Views/MenuBarView.swift index de86103..4d292bb 100644 --- a/Sources/Insomnia/Views/MenuBarView.swift +++ b/Sources/Insomnia/Views/MenuBarView.swift @@ -177,7 +177,7 @@ struct MenuBarView: View { } else if updateChecker.downloadURL != nil { // DMG available — offer direct download Button("Download v\(version)") { - Task { await updateChecker.downloadAndInstall() } + Task { await updateChecker.downloadAndOpenInstaller() } } } else { // Update exists but no DMG asset — show version info only