Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit updates for stable to the current Major.Minor (backport #881) #884

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions tools/Uno.Sdk.Updater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Uno.Sdk.Models;
using Uno.Sdk.Services;
using Uno.Sdk.Updater;
using Uno.Sdk.Updater.Utils;

const string UnoSdkPackageId = "Uno.Sdk.Private";

Expand Down Expand Up @@ -84,10 +85,16 @@
relativePackagesJsonPath = entry.FullName;
packagesJsonPath = outputPath;
using var packageStream = entry.Open();
var inputManifest = await JsonSerializer.DeserializeAsync<IEnumerable<ManifestGroup>>(packageStream);
var inputManifest = await JsonSerializer.DeserializeAsync<IEnumerable<ManifestGroup>>(packageStream)
?? throw new InvalidOperationException("Unable to parse the packages.json from the Sdk.");

if (!unoVersion.IsPreview)
{
inputManifest = MergeLocalManifest(inputManifest, outputPath);
}

var manifest = new List<ManifestGroup>();
foreach(var group in inputManifest!)
foreach(var group in inputManifest)
{
var updated = await UpdateGroup(group, unoVersion, client);
manifest.Add(updated);
Expand Down Expand Up @@ -153,6 +160,24 @@

Console.WriteLine("Finished Uno.Sdk update.");

static IEnumerable<ManifestGroup> MergeLocalManifest(IEnumerable<ManifestGroup> sdkManifest, string packagesJsonPath)
{
var localManifest = JsonSerializer.Deserialize<IEnumerable<ManifestGroup>>(File.ReadAllText(packagesJsonPath))
?? throw new InvalidOperationException("Unable to parse the packages.json from the Sdk.");
var mergedManifest = new List<ManifestGroup>(localManifest);
foreach (var group in sdkManifest)
{
if (mergedManifest.Any(x => x.Group == group.Group))
{
continue;
}

mergedManifest.Add(group);
}

return mergedManifest;
}

static void WriteIfDifferent(string filePath, string content, ref bool didWriteChanges)
{
if (!File.Exists(filePath) || !File.ReadAllText(filePath).Equals(content))
Expand Down Expand Up @@ -288,9 +313,11 @@ static async Task<ManifestGroup> UpdateGroup(ManifestGroup group, NuGetVersion u
preview = false;
}

var packageId = group.Packages.First();
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);
var version = await client.GetVersionAsync(packageId, preview, group.Version);
version = !string.IsNullOrEmpty(group.Version) && NuGetVersion.Parse(version) < NuGetVersion.Parse(group.Version) ? group.Version : version;
var newGroup = group with { Version = version };

if (group.Version != newGroup.Version)
Expand All @@ -314,6 +341,8 @@ static async Task<ManifestGroup> UpdateGroup(ManifestGroup group, NuGetVersion u
{
Console.WriteLine($"Updated Version Override for '{group.Group}' - '{key}' to '{version}'.");
}

version = NuGetVersion.Parse(version) < versionOverride ? versionOverrideString : version;
updatedOverrides.Add(key, version);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/Uno.Sdk.Updater/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Uno.Sdk powers the Uno Platform Single Project, including the ability to imp
| UnoToolkitVersion | $Toolkit$ |
| UnoThemesVersion | $Themes$ |
| UnoCSharpMarkupVersion | $CSharpMarkup$ |
| UnoWasmBootstrapVersion** | $WasmBootstrapVersion$ |
| UnoWasmBootstrapVersion** | $WasmBootstrap$ |
| UnoLoggingVersion | $OSLogging$ |
| UnoCoreLoggingSingletonVersion | $CoreLogging$ |
| UnoUniversalImageLoaderVersion | $UniversalImageLoading$ |
Expand Down
Loading
Loading