Merge pull request #3092 from eerhardt/LatestPackages
Update github.com/dotnet/versions when new CLI builds are produced.
This commit is contained in:
commit
85a4e44fa2
7 changed files with 187 additions and 105 deletions
|
@ -1,96 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build
|
|
||||||
{
|
|
||||||
public class PackageDependencies
|
|
||||||
{
|
|
||||||
internal static string[] DebianPackageBuildDependencies
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new string[]
|
|
||||||
{
|
|
||||||
"devscripts",
|
|
||||||
"debhelper",
|
|
||||||
"build-essential"
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string[] UbuntuCoreclrAndCoreFxDependencies
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new string[]
|
|
||||||
{
|
|
||||||
"libc6",
|
|
||||||
"libedit2",
|
|
||||||
"libffi6",
|
|
||||||
"libgcc1",
|
|
||||||
"libicu52",
|
|
||||||
"liblldb-3.6",
|
|
||||||
"libllvm3.6",
|
|
||||||
"liblttng-ust0",
|
|
||||||
"liblzma5",
|
|
||||||
"libncurses5",
|
|
||||||
"libpython2.7",
|
|
||||||
"libstdc++6",
|
|
||||||
"libtinfo5",
|
|
||||||
"libunwind8",
|
|
||||||
"liburcu1",
|
|
||||||
"libuuid1",
|
|
||||||
"zlib1g",
|
|
||||||
"libasn1-8-heimdal",
|
|
||||||
"libcomerr2",
|
|
||||||
"libcurl3",
|
|
||||||
"libgcrypt11",
|
|
||||||
"libgnutls26",
|
|
||||||
"libgpg-error0",
|
|
||||||
"libgssapi3-heimdal",
|
|
||||||
"libgssapi-krb5-2",
|
|
||||||
"libhcrypto4-heimdal",
|
|
||||||
"libheimbase1-heimdal",
|
|
||||||
"libheimntlm0-heimdal",
|
|
||||||
"libhx509-5-heimdal",
|
|
||||||
"libidn11",
|
|
||||||
"libk5crypto3",
|
|
||||||
"libkeyutils1",
|
|
||||||
"libkrb5-26-heimdal",
|
|
||||||
"libkrb5-3",
|
|
||||||
"libkrb5support0",
|
|
||||||
"libldap-2.4-2",
|
|
||||||
"libp11-kit0",
|
|
||||||
"libroken18-heimdal",
|
|
||||||
"librtmp0",
|
|
||||||
"libsasl2-2",
|
|
||||||
"libsqlite3-0",
|
|
||||||
"libssl1.0.0",
|
|
||||||
"libtasn1-6",
|
|
||||||
"libwind0-heimdal"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string[] CentosCoreclrAndCoreFxDependencies
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new string[]
|
|
||||||
{
|
|
||||||
"unzip",
|
|
||||||
"libunwind",
|
|
||||||
"gettext",
|
|
||||||
"libcurl-devel",
|
|
||||||
"openssl-devel",
|
|
||||||
"zlib",
|
|
||||||
"libicu-devel"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -550,6 +550,19 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
File.WriteAllText(pushedSemaphore, $"Packages pushed for build {pathToDownload}");
|
File.WriteAllText(pushedSemaphore, $"Packages pushed for build {pathToDownload}");
|
||||||
AzurePublisherTool.PublishFile(pathToDownload + "/" + PackagePushedSemaphoreFileName, pushedSemaphore);
|
AzurePublisherTool.PublishFile(pathToDownload + "/" + PackagePushedSemaphoreFileName, pushedSemaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Target(nameof(PrepareTargets.Init))]
|
||||||
|
public static BuildTargetResult UpdateVersionsRepo(BuildTargetContext c)
|
||||||
|
{
|
||||||
|
string githubAuthToken = EnvVars.EnsureVariable("GITHUB_PASSWORD");
|
||||||
|
string nupkgFilePath = EnvVars.EnsureVariable("NUPKG_FILE_PATH");
|
||||||
|
string versionsRepoPath = EnvVars.EnsureVariable("VERSIONS_REPO_PATH");
|
||||||
|
|
||||||
|
VersionRepoUpdater repoUpdater = new VersionRepoUpdater(githubAuthToken);
|
||||||
|
repoUpdater.UpdatePublishedVersions(nupkgFilePath, versionsRepoPath).Wait();
|
||||||
|
|
||||||
|
return c.Success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
|
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
|
||||||
"WindowsAzure.Storage": "6.2.2-preview",
|
"WindowsAzure.Storage": "6.2.2-preview",
|
||||||
|
|
||||||
"Microsoft.DotNet.Cli.Build.Framework": {"target":"project"},
|
"Microsoft.DotNet.Cli.Build.Framework": { "target": "project" },
|
||||||
"shared-build-targets-utils": {"target": "project"}
|
"shared-build-targets-utils": { "target": "project" }
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"netcoreapp1.0": {
|
||||||
|
@ -23,5 +23,14 @@
|
||||||
"portable-net45+win8"
|
"portable-net45+win8"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"win7-x64": { },
|
||||||
|
"win7-x86": { },
|
||||||
|
"osx.10.11-x64": { },
|
||||||
|
"ubuntu.14.04-x64": { },
|
||||||
|
"centos.7-x64": { },
|
||||||
|
"rhel.7.2-x64": { },
|
||||||
|
"debian.8-x64": { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
|
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
|
||||||
"WindowsAzure.Storage": "6.2.2-preview",
|
"WindowsAzure.Storage": "6.2.2-preview",
|
||||||
|
|
||||||
"Microsoft.DotNet.Cli.Build.Framework": {"target":"project"},
|
"Microsoft.DotNet.Cli.Build.Framework": { "target": "project" },
|
||||||
"shared-build-targets-utils": {"target": "project"}
|
"shared-build-targets-utils": { "target": "project" }
|
||||||
|
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
@ -24,5 +24,14 @@
|
||||||
"portable-net45+win8"
|
"portable-net45+win8"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"win7-x64": { },
|
||||||
|
"win7-x86": { },
|
||||||
|
"osx.10.11-x64": { },
|
||||||
|
"ubuntu.14.04-x64": { },
|
||||||
|
"centos.7-x64": { },
|
||||||
|
"rhel.7.2-x64": { },
|
||||||
|
"debian.8-x64": { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.DotNet.Cli.Build.Framework;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
|
@ -28,5 +29,16 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string EnsureVariable(string variableName)
|
||||||
|
{
|
||||||
|
string value = Environment.GetEnvironmentVariable(variableName);
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
throw new BuildFailureException($"'{variableName}' environment variable was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
135
build_projects/shared-build-targets-utils/VersionRepoUpdater.cs
Normal file
135
build_projects/shared-build-targets-utils/VersionRepoUpdater.cs
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
|
{
|
||||||
|
public class VersionRepoUpdater
|
||||||
|
{
|
||||||
|
private static Regex s_nugetFileRegex = new Regex("^(.*?)\\.(([0-9]+\\.)?[0-9]+\\.[0-9]+(-([A-z0-9-]+))?)\\.nupkg$");
|
||||||
|
|
||||||
|
private string _gitHubAuthToken;
|
||||||
|
private string _gitHubUser;
|
||||||
|
private string _gitHubEmail;
|
||||||
|
private string _versionsRepoOwner;
|
||||||
|
private string _versionsRepo;
|
||||||
|
|
||||||
|
public VersionRepoUpdater(
|
||||||
|
string gitHubAuthToken,
|
||||||
|
string gitHubUser = null,
|
||||||
|
string gitHubEmail = null,
|
||||||
|
string versionRepoOwner = null,
|
||||||
|
string versionsRepo = null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(gitHubAuthToken))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(gitHubAuthToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
_gitHubAuthToken = gitHubAuthToken;
|
||||||
|
_gitHubUser = gitHubUser ?? "dotnet-bot";
|
||||||
|
_gitHubEmail = gitHubEmail ?? "dotnet-bot@microsoft.com";
|
||||||
|
_versionsRepoOwner = versionRepoOwner ?? "dotnet";
|
||||||
|
_versionsRepo = versionsRepo ?? "versions";
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdatePublishedVersions(string nupkgFilePath, string versionsRepoPath)
|
||||||
|
{
|
||||||
|
List<NuGetPackageInfo> publishedPackages = GetPackageInfo(nupkgFilePath);
|
||||||
|
|
||||||
|
string packageInfoFileContent = string.Join(
|
||||||
|
Environment.NewLine,
|
||||||
|
publishedPackages
|
||||||
|
.OrderBy(t => t.Id)
|
||||||
|
.Select(t => $"{t.Id} {t.Version}"));
|
||||||
|
|
||||||
|
string prereleaseVersion = publishedPackages
|
||||||
|
.Where(t => !string.IsNullOrEmpty(t.Prerelease))
|
||||||
|
.Select(t => t.Prerelease)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
string packageInfoFilePath = $"{versionsRepoPath}_Packages.txt";
|
||||||
|
string message = $"Adding package info to {packageInfoFilePath} for {prereleaseVersion}";
|
||||||
|
|
||||||
|
await UpdateGitHubFile(packageInfoFilePath, packageInfoFileContent, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<NuGetPackageInfo> GetPackageInfo(string nupkgFilePath)
|
||||||
|
{
|
||||||
|
List<NuGetPackageInfo> packages = new List<NuGetPackageInfo>();
|
||||||
|
|
||||||
|
foreach (string filePath in Directory.GetFiles(nupkgFilePath, "*.nupkg"))
|
||||||
|
{
|
||||||
|
Match match = s_nugetFileRegex.Match(Path.GetFileName(filePath));
|
||||||
|
|
||||||
|
packages.Add(new NuGetPackageInfo()
|
||||||
|
{
|
||||||
|
Id = match.Groups[1].Value,
|
||||||
|
Version = match.Groups[2].Value,
|
||||||
|
Prerelease = match.Groups[5].Value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return packages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateGitHubFile(string path, string newFileContent, string commitMessage)
|
||||||
|
{
|
||||||
|
using (HttpClient client = new HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json");
|
||||||
|
client.DefaultRequestHeaders.Add("Authorization", $"token {_gitHubAuthToken}");
|
||||||
|
client.DefaultRequestHeaders.Add("User-Agent", _gitHubUser);
|
||||||
|
|
||||||
|
string fileUrl = $"https://api.github.com/repos/{_versionsRepoOwner}/{_versionsRepo}/contents/{path}";
|
||||||
|
|
||||||
|
Console.WriteLine($"Getting the 'sha' of the current contents of file '{_versionsRepoOwner}/{_versionsRepo}/{path}'");
|
||||||
|
|
||||||
|
string currentFile = await client.GetStringAsync(fileUrl);
|
||||||
|
string currentSha = JObject.Parse(currentFile)["sha"].ToString();
|
||||||
|
|
||||||
|
Console.WriteLine($"Got 'sha' value of '{currentSha}'");
|
||||||
|
|
||||||
|
Console.WriteLine($"Request to update file '{_versionsRepoOwner}/{_versionsRepo}/{path}' contents to:");
|
||||||
|
Console.WriteLine(newFileContent);
|
||||||
|
|
||||||
|
string updateFileBody = $@"{{
|
||||||
|
""message"": ""{commitMessage}"",
|
||||||
|
""committer"": {{
|
||||||
|
""name"": ""{_gitHubUser}"",
|
||||||
|
""email"": ""{_gitHubEmail}""
|
||||||
|
}},
|
||||||
|
""content"": ""{ToBase64(newFileContent)}"",
|
||||||
|
""sha"": ""{currentSha}""
|
||||||
|
}}";
|
||||||
|
|
||||||
|
Console.WriteLine("Sending request...");
|
||||||
|
StringContent content = new StringContent(updateFileBody);
|
||||||
|
|
||||||
|
using (HttpResponseMessage response = await client.PutAsync(fileUrl, content))
|
||||||
|
{
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
Console.WriteLine("Updated the file successfully...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ToBase64(string value)
|
||||||
|
{
|
||||||
|
return Convert.ToBase64String(Encoding.UTF8.GetBytes(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NuGetPackageInfo
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
|
public string Prerelease { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,16 +4,16 @@
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>b768bd29-12bf-4c7c-b093-03193fe244d1</ProjectGuid>
|
<ProjectGuid>b768bd29-12bf-4c7c-b093-03193fe244d1</ProjectGuid>
|
||||||
<RootNamespace>shared-build-targets-utils</RootNamespace>
|
<RootNamespace>Microsoft.DotNet.Cli.Build</RootNamespace>
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue