Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.DotNet.VersionTools.Automation.GitHubApi;
using Microsoft.DotNet.VersionTools.BuildManifest;
using Microsoft.DotNet.VersionTools.BuildManifest.Model;
using System.IO;
using System.Linq;
using System.Xml.Linq;

namespace Microsoft.DotNet.Build.Tasks.Feed.BuildManifest
Expand All @@ -32,6 +34,12 @@ public class PushOrchestratedBuildManifest : Task

public string CommitMessage { get; set; }

/// <summary>
/// %(Identity): A file to upload to the versions repo.
/// %(RelativePath): Optional path to upload the file to, relative to VersionsRepoPath.
/// </summary>
public ITaskItem[] SupplementaryFiles { get; set; }

public override bool Execute()
{
string contents = System.IO.File.ReadAllText(ManifestFile);
Expand All @@ -47,12 +55,28 @@ public override bool Execute()
{
var client = new BuildManifestClient(gitHubClient);

SupplementaryUploadRequest[] supplementaryUploads = SupplementaryFiles
?.Select(i =>
{
string path = i.GetMetadata("RelativePath");
if (string.IsNullOrEmpty(path))
{
path = Path.GetFileName(i.ItemSpec);
}
return new SupplementaryUploadRequest
{
Contents = File.ReadAllText(i.ItemSpec),
Path = path
};
})
.ToArray();

var pushTask = client.PushNewBuildAsync(
new GitHubProject(VersionsRepo, VersionsRepoOwner),
$"heads/{VersionsRepoBranch}",
VersionsRepoPath,
model,
null,
supplementaryUploads,
CommitMessage);

pushTask.Wait();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.VersionTools.BuildManifest.Model;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Microsoft.DotNet.Build.Tasks.Feed.BuildManifest
{
public class WriteOrchestratedBuildManifestSummaryToFile : Task
{
[Required]
public string File { get; set; }

[Required]
public string ManifestFile { get; set; }

public string SdkTableTemplateFile { get; set; }

public string RuntimeTableTemplateFile { get; set; }

public override bool Execute()
{
string contents = System.IO.File.ReadAllText(ManifestFile);
OrchestratedBuildModel model = OrchestratedBuildModel.Parse(XElement.Parse(contents));
EndpointModel blobFeed = model.Endpoints.First(e => e.IsOrchestratedBlobFeed);

string feedAssetsRoot = blobFeed.Url.Replace("/index.json", "/assets");

string sdkProductVersion = model.Builds
.FirstOrDefault(b => b.Name == "cli")
?.BuildId;
string runtimeProductVersion = blobFeed.Artifacts.Blobs
.FirstOrDefault(b => b.Id.StartsWith("Runtime/"))
?.Id.Split('/')[1];

var builder = new StringBuilder();

builder.Append("## Product build: ");
builder.AppendLine(model.Identity.ToString());

if (!string.IsNullOrEmpty(SdkTableTemplateFile) && sdkProductVersion != null)
{
builder.AppendLine();
builder.AppendLine(FillTemplate(
SdkTableTemplateFile,
feedAssetsRoot,
sdkProductVersion));
}

if (!string.IsNullOrEmpty(RuntimeTableTemplateFile) && runtimeProductVersion != null)
{
builder.AppendLine();
builder.AppendLine(FillTemplate(
RuntimeTableTemplateFile,
feedAssetsRoot,
runtimeProductVersion));
}

builder.AppendLine();
builder.AppendLine("### Built Repositories");

foreach (BuildIdentity build in model.Builds
.Where(b => b.Name != "anonymous")
.OrderBy(b => b.Name))
{
builder.Append(" * ");
builder.AppendLine(build.ToString());
}

System.IO.File.WriteAllText(File, builder.ToString());

return !Log.HasLoggedErrors;
}

private static string FillTemplate(string templateFile, string feedAssetsRoot, string productVersion)
{
return System.IO.File.ReadAllText(templateFile)
.Replace("{{FeedAssetsRoot}}", feedAssetsRoot)
.Replace("{{ProductVersion}}", productVersion);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Compile Include="BuildManifest\FetchOrchestratedBuildManifestInfo.cs" />
<Compile Include="BuildManifest\UpdateOrchestratedBuildManifest.cs" />
<Compile Include="BuildManifest\PushOrchestratedBuildManifest.cs" />
<Compile Include="BuildManifest\WriteOrchestratedBuildManifestSummaryToFile.cs" />
<Compile Include="BuildManifest\WriteOrchestratedBuildManifestToFile.cs" />
<Compile Include="ConfigureInputFeed.cs" />
<Compile Include="GetBlobFeedPackageList.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<UsingTask TaskName="PushToBlobFeed" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll"/>
<UsingTask TaskName="UpdateOrchestratedBuildManifest" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll"/>
<UsingTask TaskName="WriteOrchestratedBuildManifestToFile" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll"/>
<UsingTask TaskName="WriteOrchestratedBuildManifestSummaryToFile" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll"/>

<PropertyGroup>
<PushToBlobFeed_Overwrite Condition="'$(PushToBlobFeed_Overwrite)' == ''">false</PushToBlobFeed_Overwrite>
Expand Down Expand Up @@ -131,6 +132,7 @@
<ManifestTempDir Condition="'$(ManifestTempDir)' == ''">$(BaseIntermediateOutputPath)manifest-temp/</ManifestTempDir>
<ManifestDownloadDir Condition="'$(ManifestDownloadDir)' == ''">$(ManifestTempDir)downloads/</ManifestDownloadDir>
<ManifestFile Condition="'$(ManifestFile)' == ''">$(ManifestTempDir)build.xml</ManifestFile>
<ManifestSummaryFile Condition="'$(ManifestSummaryFile)' == ''">$(ManifestTempDir)README.md</ManifestSummaryFile>
</PropertyGroup>

<ParseBlobUrl BlobUrl="$(ExpectedFeedUrl.Replace('/index.json', ''))">
Expand All @@ -154,6 +156,15 @@
BuildManifestFiles="@(BuildManifests)"
ManifestName="$(ManifestName)"
ManifestBuildId="$(ManifestBuildId)" />

<WriteOrchestratedBuildManifestSummaryToFile File="$(ManifestSummaryFile)"
ManifestFile="$(ManifestFile)"
SdkTableTemplateFile="$(SdkTableTemplateFile)"
RuntimeTableTemplateFile="$(RuntimeTableTemplateFile)" />

<ItemGroup>
<SupplementaryFiles Include="$(ManifestSummaryFile)" />
</ItemGroup>
</Target>

<!--
Expand All @@ -175,7 +186,8 @@
VersionsRepo="$(VersionsRepo)"
VersionsRepoOwner="$(VersionsRepoOwner)"
VersionsRepoBranch="$(VersionsRepoBranch)"
CommitMessage="$(CommitMessage)" />
CommitMessage="$(CommitMessage)"
SupplementaryFiles="@(SupplementaryFiles)" />

</Target>

Expand Down