Skip to content

Commit

Permalink
fix: Don't upgrade majors for skiasharp and bootstrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Oct 25, 2024
1 parent 75babbe commit f21b5fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 11 additions & 2 deletions tools/Uno.Sdk.Updater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,21 @@ static async Task<ManifestGroup> UpdateGroup(ManifestGroup group, NuGetVersion u
}

var preview = unoVersion.IsPreview;

string[] stableOnlyGroups = [
"CoreLogging",
"OSLogging",
"UniversalImageLoading",
"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;
Expand All @@ -320,7 +328,8 @@ static async Task<ManifestGroup> 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 };

Expand All @@ -340,7 +349,7 @@ static async Task<ManifestGroup> 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}'.");
Expand Down
8 changes: 7 additions & 1 deletion tools/Uno.Sdk.Updater/Services/NuGetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,19 @@ private async Task<IEnumerable<string>> GetPublicPackageVersions(string packageI
}
}

public async Task<string> GetVersionAsync(string packageId, bool preview, string? minimumVersionString = null)
public async Task<string> 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)
Expand Down

0 comments on commit f21b5fd

Please sign in to comment.