From 9c7cb7439f92f481b7db3bf794a476a06da49320 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sun, 1 Mar 2026 13:11:11 +0100 Subject: [PATCH] feat: add winget package manager support --- .../{update-cask.yml => update-packages.yml} | 13 +++++++-- lib/services/update_service.dart | 13 ++++++++- windows/build-installer.ps1 | 29 +++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) rename .github/workflows/{update-cask.yml => update-packages.yml} (83%) diff --git a/.github/workflows/update-cask.yml b/.github/workflows/update-packages.yml similarity index 83% rename from .github/workflows/update-cask.yml rename to .github/workflows/update-packages.yml index 9e2b5af5..03b0af8e 100644 --- a/.github/workflows/update-cask.yml +++ b/.github/workflows/update-packages.yml @@ -1,4 +1,4 @@ -name: Update Homebrew Cask +name: Update Packages on: release: @@ -6,7 +6,7 @@ on: workflow_dispatch: jobs: - update-cask: + update-homebrew: runs-on: macos-latest permissions: contents: write @@ -43,3 +43,12 @@ jobs: else echo "No cask changes to commit." fi + + update-winget: + runs-on: windows-latest + steps: + - uses: vedantmgoyal9/winget-releaser@v2 + with: + identifier: edde746.Plezy + installers-regex: 'plezy-windows-installer\.exe$' + token: ${{ secrets.WINGET_TOKEN }} diff --git a/lib/services/update_service.dart b/lib/services/update_service.dart index 0b0d7dc6..d25c9e48 100644 --- a/lib/services/update_service.dart +++ b/lib/services/update_service.dart @@ -36,7 +36,7 @@ class UpdateService { static bool get useNativeUpdater { if (!isUpdateCheckEnabled) return false; if (Platform.isMacOS) return !_isHomebrewInstall(); - if (Platform.isWindows) return _isInstalledApp(); + if (Platform.isWindows) return _isInstalledApp() && !_isWingetInstall(); return false; } @@ -77,6 +77,17 @@ class UpdateService { } } + /// Check if the Windows app was installed via winget. + /// The Inno Setup installer writes a .winget marker file when invoked with /WINGET=1. + static bool _isWingetInstall() { + try { + final exeDir = File(Platform.resolvedExecutable).parent.path; + return File('$exeDir\\.winget').existsSync(); + } catch (_) { + return false; + } + } + /// Check if the Windows app is an installed copy (not portable). /// The Inno Setup installer places unins000.exe next to the executable. static bool _isInstalledApp() { diff --git a/windows/build-installer.ps1 b/windows/build-installer.ps1 index 00c24e3c..8218063e 100644 --- a/windows/build-installer.ps1 +++ b/windows/build-installer.ps1 @@ -156,6 +156,20 @@ function IsX64: Boolean; begin Result := not IsArm64; end; + +procedure CurStepChanged(CurStep: TSetupStep); +var + MarkerPath: String; +begin + if CurStep = ssPostInstall then + begin + MarkerPath := ExpandConstant('{app}\.winget'); + if ExpandConstant('{param:WINGET|0}') = '1' then + SaveStringToFile(MarkerPath, '', False) + else + DeleteFile(MarkerPath); + end; +end; "@ } else { # Single-arch installer (backward compatible, no Check: functions needed) @@ -206,6 +220,21 @@ Name: "{autodesktop}\{#Name}"; Filename: "{app}\{#ExeName}"; Tasks: desktopicon [Run] Filename: "{app}\{#ExeName}"; Description: "{cm:LaunchProgram,{#Name}}"; Flags: nowait postinstall + +[Code] +procedure CurStepChanged(CurStep: TSetupStep); +var + MarkerPath: String; +begin + if CurStep = ssPostInstall then + begin + MarkerPath := ExpandConstant('{app}\.winget'); + if ExpandConstant('{param:WINGET|0}') = '1' then + SaveStringToFile(MarkerPath, '', False) + else + DeleteFile(MarkerPath); + end; +end; "@ }