From f21b5fdcb028d32f293a1e55c12c155a25a9428b Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Fri, 25 Oct 2024 07:57:44 -0400 Subject: [PATCH] fix: Don't upgrade majors for skiasharp and bootstrapper --- tools/Uno.Sdk.Updater/Program.cs | 13 +++++++++++-- tools/Uno.Sdk.Updater/Services/NuGetClient.cs | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/Uno.Sdk.Updater/Program.cs b/tools/Uno.Sdk.Updater/Program.cs index 8aff70623..b60ef40cb 100644 --- a/tools/Uno.Sdk.Updater/Program.cs +++ b/tools/Uno.Sdk.Updater/Program.cs @@ -301,6 +301,7 @@ static async Task UpdateGroup(ManifestGroup group, NuGetVersion u } var preview = unoVersion.IsPreview; + string[] stableOnlyGroups = [ "CoreLogging", "OSLogging", @@ -308,6 +309,13 @@ static async Task UpdateGroup(ManifestGroup group, NuGetVersion u "WasmBootstrap" ]; + // Those groups have major versions update disabled + // as they are generally containing breaking changes. + string[] majorUpgradeDisabledGroups = [ + "SkiaSharp", + "WasmBootstrap" + ]; + if (stableOnlyGroups.Any(x => x == group.Group)) { preview = false; @@ -320,7 +328,8 @@ static async Task UpdateGroup(ManifestGroup group, NuGetVersion u var packageId = group.Packages.FirstOrDefault(x => x.Contains("WinUI", StringComparison.InvariantCultureIgnoreCase) && x.Contains("Uno", StringComparison.InvariantCultureIgnoreCase)) ?? group.Packages.First(); - var version = await client.GetVersionAsync(packageId, preview, group.Version); + var noMajorUpgrade = majorUpgradeDisabledGroups.Any(x => x == group.Group); + var version = await client.GetVersionAsync(packageId, preview, noMajorUpgrade, group.Version); version = !string.IsNullOrEmpty(group.Version) && NuGetVersion.Parse(version) < NuGetVersion.Parse(group.Version) ? group.Version : version; var newGroup = group with { Version = version }; @@ -340,7 +349,7 @@ static async Task UpdateGroup(ManifestGroup group, NuGetVersion u continue; } - version = await client.GetVersionAsync(packageId, versionOverride.IsPreview, versionOverride.OriginalVersion); + version = await client.GetVersionAsync(packageId, versionOverride.IsPreview, noMajorUpgrade, versionOverride.OriginalVersion); if (version != versionOverrideString) { Console.WriteLine($"Updated Version Override for '{group.Group}' - '{key}' to '{version}'."); diff --git a/tools/Uno.Sdk.Updater/Services/NuGetClient.cs b/tools/Uno.Sdk.Updater/Services/NuGetClient.cs index b1fc1e291..7256963c9 100644 --- a/tools/Uno.Sdk.Updater/Services/NuGetClient.cs +++ b/tools/Uno.Sdk.Updater/Services/NuGetClient.cs @@ -243,13 +243,19 @@ private async Task> GetPublicPackageVersions(string packageI } } - public async Task GetVersionAsync(string packageId, bool preview, string? minimumVersionString = null) + public async Task GetVersionAsync(string packageId, bool preview, bool majorUpgradeDisabled, string? minimumVersionString = null) { var versions = await GetPackageVersions(packageId); + // https://api.nuget.org/v3-flatcontainer/uno.extensions.hosting.winui/4.2.0-dev.137/uno.extensions.hosting.winui.nuspec if (!string.IsNullOrEmpty(minimumVersionString) && NuGetVersion.TryParse(minimumVersionString, out var minimumVersion)) { + if (majorUpgradeDisabled) + { + versions = versions.Where(v => v.Version.Major <= minimumVersion.Version.Major); + } + versions = versions.Where(x => minimumVersion.Version <= x.Version); if (UnoVersion.HasValue && !UnoVersion.Value.IsPreview)