Skip to content

Commit d727264

Browse files
Add release draft option and updater fallback
1 parent 7818dc2 commit d727264

File tree

3 files changed

+74
-7
lines changed

3 files changed

+74
-7
lines changed

.github/workflows/build-release.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
description: 'Release version (e.g. 3.3.7)'
88
default: "latest"
99
required: true
10+
draft-release:
11+
description: 'Create the GitHub Release as a draft'
12+
required: true
13+
type: boolean
14+
default: false
1015
skip-publish:
1116
description: 'Skip publishing to GitHub Releases'
1217
required: true
@@ -25,6 +30,7 @@ jobs:
2530
outputs:
2631
package-env: ${{ steps.info.outputs.package-env }}
2732
package-version: ${{ steps.info.outputs.package-version }}
33+
draft-release: ${{ steps.info.outputs.draft-release }}
2834
skip-publish: ${{ steps.info.outputs.skip-publish }}
2935
dry-run: ${{ steps.info.outputs.dry-run }}
3036

@@ -38,6 +44,7 @@ jobs:
3844
run: |
3945
$IsProductionBranch = @('main', 'master') -contains '${{ github.ref_name }}'
4046
47+
try { $DraftRelease = [System.Boolean]::Parse('${{ inputs.draft-release }}') } catch { $DraftRelease = $false }
4148
try { $SkipPublish = [System.Boolean]::Parse('${{ inputs.skip-publish }}') } catch { $SkipPublish = $false }
4249
try { $DryRun = [System.Boolean]::Parse('${{ inputs.dry-run }}') } catch { $DryRun = $true }
4350
@@ -68,11 +75,13 @@ jobs:
6875
6976
echo "package-env=$PackageEnv" >> $Env:GITHUB_OUTPUT
7077
echo "package-version=$PackageVersion" >> $Env:GITHUB_OUTPUT
78+
echo "draft-release=$($DraftRelease.ToString().ToLower())" >> $Env:GITHUB_OUTPUT
7179
echo "skip-publish=$($SkipPublish.ToString().ToLower())" >> $Env:GITHUB_OUTPUT
7280
echo "dry-run=$($DryRun.ToString().ToLower())" >> $Env:GITHUB_OUTPUT
7381
7482
echo "::notice::Environment: $PackageEnv"
7583
echo "::notice::Version: $PackageVersion"
84+
echo "::notice::DraftRelease: $DraftRelease"
7685
echo "::notice::DryRun: $DryRun"
7786
7887
build:
@@ -316,6 +325,7 @@ jobs:
316325
working-directory: output
317326
run: |
318327
$PackageVersion = '${{ needs.preflight.outputs.package-version }}'
328+
$DraftRelease = [System.Boolean]::Parse('${{ needs.preflight.outputs.draft-release }}')
319329
$DryRun = [System.Boolean]::Parse('${{ needs.preflight.outputs.dry-run }}')
320330
321331
echo "::group::checksums"
@@ -325,15 +335,20 @@ jobs:
325335
$ReleaseTag = "v$PackageVersion"
326336
$ReleaseTitle = "UniGetUI v${PackageVersion}"
327337
$Repository = $Env:GITHUB_REPOSITORY
338+
$DraftArg = if ($DraftRelease) { '--draft' } else { $null }
328339
329340
$Files = Get-ChildItem -Path . -Recurse -File | Where-Object {
330341
$_.Name -eq 'checksums.txt' -or $_.Name -notmatch '^checksums\..+\.txt$'
331342
}
332343
333344
if ($DryRun) {
334345
Write-Host "Dry Run: skipping GitHub release creation!"
335-
Write-Host "Would create release $ReleaseTag with title '$ReleaseTitle'"
346+
Write-Host "Would create release $ReleaseTag with title '$ReleaseTitle' (draft=$DraftRelease)"
336347
$Files | ForEach-Object { Write-Host " - $($_.FullName)" }
337348
} else {
338-
& gh release create $ReleaseTag --repo $Repository --title $ReleaseTitle $Files.FullName
349+
if ($DraftArg) {
350+
& gh release create $ReleaseTag --repo $Repository --title $ReleaseTitle $DraftArg $Files.FullName
351+
} else {
352+
& gh release create $ReleaseTag --repo $Repository --title $ReleaseTitle $Files.FullName
353+
}
339354
}

src/UniGetUI/AutoUpdater.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ public static async Task<bool> CheckAndInstallUpdates(Window window, InfoBar ban
9898
);
9999

100100
// Check for updates
101-
UpdateCandidate updateCandidate = updaterOverrides.UseLegacyGithub
102-
? await CheckForUpdatesFromLegacyGitHub(updaterOverrides)
103-
: await CheckForUpdatesFromProductInfo(updaterOverrides);
101+
UpdateCandidate updateCandidate = await GetUpdateCandidate(updaterOverrides);
102+
Logger.Info($"Updater source '{updateCandidate.SourceName}' returned version {updateCandidate.VersionName} (upgradable={updateCandidate.IsUpgradable})");
104103

105104
if (updateCandidate.IsUpgradable)
106105
{
@@ -166,6 +165,25 @@ public static async Task<bool> CheckAndInstallUpdates(Window window, InfoBar ban
166165
}
167166
}
168167

168+
private static async Task<UpdateCandidate> GetUpdateCandidate(UpdaterOverrides updaterOverrides)
169+
{
170+
if (updaterOverrides.UseLegacyGithub)
171+
{
172+
return await CheckForUpdatesFromLegacyGitHub(updaterOverrides);
173+
}
174+
175+
try
176+
{
177+
return await CheckForUpdatesFromProductInfo(updaterOverrides);
178+
}
179+
catch (Exception ex)
180+
{
181+
Logger.Warn("Productinfo updater source failed. Falling back to legacy GitHub updater source.");
182+
Logger.Warn(ex);
183+
return await CheckForUpdatesFromLegacyGitHub(updaterOverrides);
184+
}
185+
}
186+
169187
/// <summary>
170188
/// Default update source using Devolutions productinfo.json
171189
/// </summary>

testing/UPDATE-TESTING.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This guide validates the new default auto-update flow that reads from `productinfo.json`.
44

5+
If `productinfo.json` lookup fails for any reason, UniGetUI now falls back to the legacy updater logic that uses the existing version endpoint and GitHub release download URL.
6+
57
## Files used
68

79
- `testing/productinfo.unigetui.test.json`
@@ -114,15 +116,47 @@ Expected result:
114116
- Legacy endpoint/GitHub code path is used.
115117
- Productinfo path is bypassed for that run.
116118

117-
## 7) Optional: disable signer thumbprint check (test-only)
119+
## 7) Fallback test: broken productinfo with successful legacy fallback
120+
121+
Use one of these methods:
122+
123+
- Point `UpdaterProductInfoUrl` to a missing URL, or
124+
- Point `UpdaterProductInfoUrl` to a malformed JSON file, or
125+
- Point `UpdaterProductKey` to a non-existent product.
126+
127+
Example:
128+
129+
```powershell
130+
Set-ItemProperty -Path 'HKCU:\Software\Devolutions\UniGetUI' -Name 'UpdaterProductInfoUrl' -Value 'http://127.0.0.1:8080/does-not-exist.json'
131+
Set-ItemProperty -Path 'HKCU:\Software\Devolutions\UniGetUI' -Name 'UpdaterUseLegacyGithub' -Type DWord -Value 0
132+
```
133+
134+
Expected result:
135+
136+
- Productinfo check fails.
137+
- UniGetUI logs that it is falling back to the legacy GitHub updater source.
138+
- Legacy updater path is used automatically.
139+
- If the legacy source has a newer version, the update flow continues normally.
140+
141+
## 8) Fallback test: both sources fail
142+
143+
Use a broken productinfo override and also make the legacy source unavailable in your test environment.
144+
145+
Expected result:
146+
147+
- Productinfo check fails first.
148+
- UniGetUI attempts the legacy updater path.
149+
- The updater shows the existing terminal error because neither source succeeded.
150+
151+
## 9) Optional: disable signer thumbprint check (test-only)
118152

119153
Use this only if your local installer is unsigned or signed with a non-Devolutions certificate.
120154

121155
```powershell
122156
Set-ItemProperty -Path 'HKCU:\Software\Devolutions\UniGetUI' -Name 'UpdaterSkipSignerThumbprintCheck' -Type DWord -Value 1
123157
```
124158

125-
## 8) Cleanup after testing
159+
## 10) Cleanup after testing
126160

127161
Reset to default production behavior:
128162

0 commit comments

Comments
 (0)