2016-02-15 18:07:39 +00:00
|
|
|
|
using System;
|
2016-04-25 20:17:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-02-12 18:11:30 +00:00
|
|
|
|
using System.IO;
|
2016-04-25 20:17:46 +00:00
|
|
|
|
using System.Linq;
|
2016-03-16 21:39:02 +00:00
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
2016-02-15 18:07:39 +00:00
|
|
|
|
using Microsoft.DotNet.Cli.Build.Framework;
|
2016-03-07 20:20:50 +00:00
|
|
|
|
using Microsoft.WindowsAzure.Storage;
|
|
|
|
|
using Microsoft.WindowsAzure.Storage.Blob;
|
2016-02-12 18:11:30 +00:00
|
|
|
|
|
|
|
|
|
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
|
|
|
{
|
|
|
|
|
public static class PublishTargets
|
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
private static AzurePublisher AzurePublisherTool { get; set; }
|
|
|
|
|
|
|
|
|
|
private static DebRepoPublisher DebRepoPublisherTool { get; set; }
|
2016-03-07 20:20:50 +00:00
|
|
|
|
|
2016-03-07 22:52:41 +00:00
|
|
|
|
private static string Channel { get; set; }
|
2016-03-07 20:20:50 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
private static string CliVersion { get; set; }
|
2016-03-07 20:20:50 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
private static string CliNuGetVersion { get; set; }
|
2016-03-18 05:22:22 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
private static string SharedFrameworkNugetVersion { get; set; }
|
2016-03-07 20:20:50 +00:00
|
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
|
public static BuildTargetResult InitPublish(BuildTargetContext c)
|
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
AzurePublisherTool = new AzurePublisher();
|
|
|
|
|
DebRepoPublisherTool = new DebRepoPublisher(Dirs.Packages);
|
2016-03-07 20:20:50 +00:00
|
|
|
|
|
2016-03-24 00:13:58 +00:00
|
|
|
|
CliVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
|
|
|
|
CliNuGetVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
|
2016-03-23 23:37:59 +00:00
|
|
|
|
SharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
|
2016-03-07 22:52:41 +00:00
|
|
|
|
Channel = c.BuildContext.Get<string>("Channel");
|
2016-03-23 23:37:59 +00:00
|
|
|
|
|
2016-03-07 20:20:50 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target(nameof(PrepareTargets.Init),
|
|
|
|
|
nameof(PublishTargets.InitPublish),
|
2016-03-24 17:50:29 +00:00
|
|
|
|
nameof(PublishTargets.PublishArtifacts),
|
2016-04-25 20:17:46 +00:00
|
|
|
|
nameof(PublishTargets.TriggerDockerHubBuilds),
|
|
|
|
|
nameof(PublishTargets.FinalizeBuild))]
|
2016-03-07 22:52:41 +00:00
|
|
|
|
[Environment("PUBLISH_TO_AZURE_BLOB", "1", "true")] // This is set by CI systems
|
2016-02-12 18:11:30 +00:00
|
|
|
|
public static BuildTargetResult Publish(BuildTargetContext c)
|
|
|
|
|
{
|
2016-03-07 20:20:50 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
2016-02-16 19:39:17 +00:00
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
[Target]
|
|
|
|
|
public static BuildTargetResult FinalizeBuild(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
if (CheckIfAllBuildsHavePublished())
|
|
|
|
|
{
|
|
|
|
|
string targetContainer = $"{Channel}/Binaries/Latest/";
|
|
|
|
|
string targetVersionFile = $"{targetContainer}{CliNuGetVersion}";
|
2016-04-29 21:05:41 +00:00
|
|
|
|
string semaphoreBlob = $"{Channel}/Binaries/publishSemaphore";
|
|
|
|
|
AzurePublisherTool.CreateBlobIfNotExists(semaphoreBlob);
|
|
|
|
|
string leaseId = AzurePublisherTool.AcquireLeaseOnBlob(semaphoreBlob);
|
2016-04-25 20:17:46 +00:00
|
|
|
|
|
|
|
|
|
// Prevent race conditions by dropping a version hint of what version this is. If we see this file
|
|
|
|
|
// and it is the same as our version then we know that a race happened where two+ builds finished
|
|
|
|
|
// at the same time and someone already took care of publishing and we have no work to do.
|
|
|
|
|
if (AzurePublisherTool.IsLatestSpecifiedVersion(targetVersionFile))
|
|
|
|
|
{
|
2016-05-02 08:03:31 +00:00
|
|
|
|
AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
|
2016-04-25 20:17:46 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// This is an old drop of latest so remove all old files to ensure a clean state
|
2016-05-02 08:03:31 +00:00
|
|
|
|
AzurePublisherTool.ListBlobs($"{targetContainer}")
|
|
|
|
|
.Select(s => s.Replace("/dotnet/", ""))
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(f => AzurePublisherTool.TryDeleteBlob(f));
|
2016-04-25 20:17:46 +00:00
|
|
|
|
|
|
|
|
|
// Drop the version file signaling such for any race-condition builds (see above comment).
|
|
|
|
|
AzurePublisherTool.DropLatestSpecifiedVersion(targetVersionFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-05-02 17:32:28 +00:00
|
|
|
|
// Copy the latest CLI bits
|
|
|
|
|
CopyBlobs($"{Channel}/Binaries/{CliNuGetVersion}/", targetContainer);
|
|
|
|
|
|
|
|
|
|
// Copy the latest installer files
|
|
|
|
|
CopyBlobs($"{Channel}/Installers/{CliNuGetVersion}/", $"{Channel}/Installers/Latest/");
|
|
|
|
|
|
|
|
|
|
// Copy the shared framework installers
|
|
|
|
|
CopyBlobs($"{Channel}/Installers/{SharedFrameworkNugetVersion}/", $"{Channel}/Installers/Latest/");
|
|
|
|
|
|
|
|
|
|
// Copy the shared framework
|
|
|
|
|
CopyBlobs($"{Channel}/Binaries/{SharedFrameworkNugetVersion}/", targetContainer);
|
2016-04-25 20:17:46 +00:00
|
|
|
|
|
|
|
|
|
// Generate the CLI and SDK Version text files
|
|
|
|
|
List<string> versionFiles = new List<string>() { "win.x86.version", "win.x64.version", "ubuntu.x64.version", "rhel.x64.version", "osx.x64.version", "debian.x64.version", "centos.x64.version" };
|
|
|
|
|
string cliVersion = Utils.GetCliVersionFileContent(c);
|
|
|
|
|
string sfxVersion = Utils.GetSharedFrameworkVersionFileContent(c);
|
|
|
|
|
foreach (string version in versionFiles)
|
|
|
|
|
{
|
|
|
|
|
AzurePublisherTool.PublishStringToBlob($"{Channel}/dnvm/latest.{version}", cliVersion);
|
|
|
|
|
AzurePublisherTool.PublishStringToBlob($"{Channel}/dnvm/latest.sharedfx.{version}", sfxVersion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
2016-05-02 16:54:10 +00:00
|
|
|
|
AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
|
2016-04-25 20:17:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 17:32:28 +00:00
|
|
|
|
private static void CopyBlobs(string sourceFolder, string destinationFolder)
|
|
|
|
|
{
|
|
|
|
|
foreach (string blob in AzurePublisherTool.ListBlobs(sourceFolder))
|
|
|
|
|
{
|
|
|
|
|
string source = blob.Replace("/dotnet/", "");
|
|
|
|
|
string targetName = Path.GetFileName(blob)
|
|
|
|
|
.Replace(CliNuGetVersion, "latest")
|
|
|
|
|
.Replace(SharedFrameworkNugetVersion, "latest");
|
|
|
|
|
string target = $"{destinationFolder}{targetName}";
|
|
|
|
|
AzurePublisherTool.CopyBlob(source, target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
private static bool CheckIfAllBuildsHavePublished()
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, bool> badges = new Dictionary<string, bool>()
|
|
|
|
|
{
|
|
|
|
|
{ "Windows_x86", false },
|
|
|
|
|
{ "Windows_x64", false },
|
|
|
|
|
{ "Ubuntu_x64", false },
|
|
|
|
|
{ "RHEL_x64", false },
|
|
|
|
|
{ "OSX_x64", false },
|
|
|
|
|
{ "Debian_x64", false },
|
|
|
|
|
{ "CentOS_x64", false }
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-02 17:32:28 +00:00
|
|
|
|
List<string> blobs = new List<string>(AzurePublisherTool.ListBlobs($"{Channel}/Binaries/{CliNuGetVersion}/"));
|
2016-04-25 20:17:46 +00:00
|
|
|
|
|
|
|
|
|
var config = Environment.GetEnvironmentVariable("CONFIGURATION");
|
|
|
|
|
var versionBadgeName = $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}";
|
|
|
|
|
if (badges.ContainsKey(versionBadgeName) == false)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("A new OS build was added without adding the moniker to the {nameof(badges)} lookup");
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 17:32:28 +00:00
|
|
|
|
foreach (string file in blobs)
|
2016-04-25 20:17:46 +00:00
|
|
|
|
{
|
|
|
|
|
string name = Path.GetFileName(file);
|
|
|
|
|
string key = string.Empty;
|
|
|
|
|
|
|
|
|
|
foreach (string img in badges.Keys)
|
|
|
|
|
{
|
|
|
|
|
if ((name.StartsWith($"{img}")) && (name.EndsWith(".svg")))
|
|
|
|
|
{
|
|
|
|
|
key = img;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(key) == false)
|
|
|
|
|
{
|
|
|
|
|
badges[key] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return badges.Keys.All(key => badges[key]);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 09:23:24 +00:00
|
|
|
|
[Target(
|
2016-03-23 23:37:59 +00:00
|
|
|
|
nameof(PublishTargets.PublishInstallerFilesToAzure),
|
|
|
|
|
nameof(PublishTargets.PublishArchivesToAzure),
|
2016-03-22 21:14:54 +00:00
|
|
|
|
nameof(PublishTargets.PublishDebFilesToDebianRepo),
|
2016-03-31 00:59:16 +00:00
|
|
|
|
nameof(PublishTargets.PublishCoreHostPackages),
|
2016-03-23 23:37:59 +00:00
|
|
|
|
nameof(PublishTargets.PublishCliVersionBadge))]
|
|
|
|
|
public static BuildTargetResult PublishArtifacts(BuildTargetContext c) => c.Success();
|
|
|
|
|
|
|
|
|
|
[Target(
|
|
|
|
|
nameof(PublishTargets.PublishSharedHostInstallerFileToAzure),
|
|
|
|
|
nameof(PublishTargets.PublishSharedFrameworkInstallerFileToAzure),
|
|
|
|
|
nameof(PublishTargets.PublishSdkInstallerFileToAzure),
|
|
|
|
|
nameof(PublishTargets.PublishCombinedFrameworkSDKHostInstallerFileToAzure),
|
|
|
|
|
nameof(PublishTargets.PublishCombinedFrameworkHostInstallerFileToAzure))]
|
|
|
|
|
public static BuildTargetResult PublishInstallerFilesToAzure(BuildTargetContext c) => c.Success();
|
|
|
|
|
|
|
|
|
|
[Target(
|
|
|
|
|
nameof(PublishTargets.PublishCombinedHostFrameworkArchiveToAzure),
|
2016-04-05 03:13:13 +00:00
|
|
|
|
nameof(PublishTargets.PublishCombinedHostFrameworkSdkArchiveToAzure),
|
2016-04-24 20:01:52 +00:00
|
|
|
|
nameof(PublishTargets.PublishCombinedFrameworkSDKArchiveToAzure),
|
2016-04-05 03:13:13 +00:00
|
|
|
|
nameof(PublishTargets.PublishSDKSymbolsArchiveToAzure))]
|
2016-03-23 23:37:59 +00:00
|
|
|
|
public static BuildTargetResult PublishArchivesToAzure(BuildTargetContext c) => c.Success();
|
|
|
|
|
|
|
|
|
|
[Target(
|
|
|
|
|
nameof(PublishSdkDebToDebianRepo),
|
|
|
|
|
nameof(PublishSharedFrameworkDebToDebianRepo),
|
|
|
|
|
nameof(PublishSharedHostDebToDebianRepo))]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
|
|
|
|
public static BuildTargetResult PublishDebFilesToDebianRepo(BuildTargetContext c)
|
2016-03-07 20:20:50 +00:00
|
|
|
|
{
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
2016-02-12 18:11:30 +00:00
|
|
|
|
|
2016-03-07 20:20:50 +00:00
|
|
|
|
[Target]
|
2016-03-23 23:37:59 +00:00
|
|
|
|
public static BuildTargetResult PublishCliVersionBadge(BuildTargetContext c)
|
2016-03-07 20:20:50 +00:00
|
|
|
|
{
|
2016-03-24 00:13:58 +00:00
|
|
|
|
var versionBadge = c.BuildContext.Get<string>("VersionBadge");
|
|
|
|
|
var versionBadgeBlob = $"{Channel}/Binaries/{CliNuGetVersion}/{Path.GetFileName(versionBadge)}";
|
|
|
|
|
AzurePublisherTool.PublishFile(versionBadgeBlob, versionBadge);
|
2016-03-23 23:37:59 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-31 00:59:16 +00:00
|
|
|
|
[Target]
|
|
|
|
|
public static BuildTargetResult PublishCoreHostPackages(BuildTargetContext c)
|
|
|
|
|
{
|
2016-04-22 02:18:05 +00:00
|
|
|
|
foreach (var file in Directory.GetFiles(Dirs.CorehostLocalPackages, "*.nupkg"))
|
2016-03-31 00:59:16 +00:00
|
|
|
|
{
|
|
|
|
|
var hostBlob = $"{Channel}/Binaries/{CliNuGetVersion}/{Path.GetFileName(file)}";
|
|
|
|
|
AzurePublisherTool.PublishFile(hostBlob, file);
|
2016-04-06 22:28:12 +00:00
|
|
|
|
Console.WriteLine($"Publishing package {hostBlob} to Azure.");
|
2016-03-31 00:59:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
[Target]
|
2016-04-24 20:01:52 +00:00
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu, BuildPlatform.Windows)]
|
2016-03-23 23:37:59 +00:00
|
|
|
|
public static BuildTargetResult PublishSharedHostInstallerFileToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = CliNuGetVersion;
|
|
|
|
|
var installerFile = c.BuildContext.Get<string>("SharedHostInstallerFile");
|
|
|
|
|
|
2016-04-24 20:01:52 +00:00
|
|
|
|
if (CurrentPlatform.Current == BuildPlatform.Windows)
|
|
|
|
|
{
|
|
|
|
|
installerFile = Path.ChangeExtension(installerFile, "msi");
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishInstallerFile(installerFile, Channel, version);
|
2016-04-06 22:28:12 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
|
|
|
|
public static BuildTargetResult PublishSharedFrameworkInstallerFileToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = SharedFrameworkNugetVersion;
|
|
|
|
|
var installerFile = c.BuildContext.Get<string>("SharedFrameworkInstallerFile");
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishInstallerFile(installerFile, Channel, version);
|
2016-04-06 22:28:12 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
|
|
|
|
public static BuildTargetResult PublishSdkInstallerFileToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = CliNuGetVersion;
|
2016-03-24 00:13:58 +00:00
|
|
|
|
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
2016-03-23 23:37:59 +00:00
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishInstallerFile(installerFile, Channel, version);
|
2016-03-23 23:37:59 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX)]
|
|
|
|
|
public static BuildTargetResult PublishCombinedFrameworkHostInstallerFileToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = SharedFrameworkNugetVersion;
|
|
|
|
|
var installerFile = c.BuildContext.Get<string>("CombinedFrameworkHostInstallerFile");
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishInstallerFile(installerFile, Channel, version);
|
2016-02-12 18:11:30 +00:00
|
|
|
|
|
2016-03-07 20:20:50 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target]
|
2016-03-23 01:31:16 +00:00
|
|
|
|
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX)]
|
2016-03-23 23:37:59 +00:00
|
|
|
|
public static BuildTargetResult PublishCombinedFrameworkSDKHostInstallerFileToAzure(BuildTargetContext c)
|
2016-03-07 20:20:50 +00:00
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var version = CliNuGetVersion;
|
2016-03-17 01:16:51 +00:00
|
|
|
|
var installerFile = c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile");
|
2016-03-07 20:20:50 +00:00
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishInstallerFile(installerFile, Channel, version);
|
2016-03-23 23:37:59 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-24 20:01:52 +00:00
|
|
|
|
[Target]
|
2016-04-26 21:33:40 +00:00
|
|
|
|
[BuildPlatforms(BuildPlatform.Windows)]
|
2016-04-24 20:01:52 +00:00
|
|
|
|
public static BuildTargetResult PublishCombinedFrameworkSDKArchiveToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = CliNuGetVersion;
|
|
|
|
|
var archiveFile = c.BuildContext.Get<string>("CombinedFrameworkSDKCompressedFile");
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishArchive(archiveFile, Channel, version);
|
2016-04-24 20:01:52 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
[Target]
|
|
|
|
|
public static BuildTargetResult PublishCombinedHostFrameworkSdkArchiveToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = CliNuGetVersion;
|
|
|
|
|
var archiveFile = c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile");
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishArchive(archiveFile, Channel, version);
|
2016-03-23 23:37:59 +00:00
|
|
|
|
|
2016-03-07 20:20:50 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-05 03:13:13 +00:00
|
|
|
|
[Target]
|
|
|
|
|
public static BuildTargetResult PublishSDKSymbolsArchiveToAzure(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
var version = CliNuGetVersion;
|
|
|
|
|
var archiveFile = c.BuildContext.Get<string>("SdkSymbolsCompressedFile");
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishArchive(archiveFile, Channel, version);
|
2016-04-05 03:13:13 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-07 20:20:50 +00:00
|
|
|
|
[Target]
|
2016-03-23 23:37:59 +00:00
|
|
|
|
public static BuildTargetResult PublishCombinedHostFrameworkArchiveToAzure(BuildTargetContext c)
|
2016-03-07 20:20:50 +00:00
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var version = SharedFrameworkNugetVersion;
|
|
|
|
|
var archiveFile = c.BuildContext.Get<string>("CombinedFrameworkHostCompressedFile");
|
|
|
|
|
|
2016-04-25 20:17:46 +00:00
|
|
|
|
AzurePublisherTool.PublishArchive(archiveFile, Channel, version);
|
2016-03-22 21:14:54 +00:00
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
|
|
|
|
public static BuildTargetResult PublishSdkDebToDebianRepo(BuildTargetContext c)
|
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var version = CliNuGetVersion;
|
|
|
|
|
|
2016-03-22 21:14:54 +00:00
|
|
|
|
var packageName = Monikers.GetSdkDebianPackageName(c);
|
2016-03-08 21:39:41 +00:00
|
|
|
|
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var uploadUrl = AzurePublisherTool.CalculateInstallerUploadUrl(installerFile, Channel, version);
|
2016-03-08 23:33:18 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
DebRepoPublisherTool.PublishDebFileToDebianRepo(
|
2016-04-06 22:28:12 +00:00
|
|
|
|
packageName,
|
|
|
|
|
version,
|
2016-03-23 23:37:59 +00:00
|
|
|
|
uploadUrl);
|
2016-03-08 23:33:18 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-22 21:14:54 +00:00
|
|
|
|
[Target]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
|
|
|
|
public static BuildTargetResult PublishSharedFrameworkDebToDebianRepo(BuildTargetContext c)
|
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var version = SharedFrameworkNugetVersion;
|
|
|
|
|
|
2016-04-06 01:48:02 +00:00
|
|
|
|
var packageName = Monikers.GetDebianSharedFrameworkPackageName(c);
|
2016-03-22 21:14:54 +00:00
|
|
|
|
var installerFile = c.BuildContext.Get<string>("SharedFrameworkInstallerFile");
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var uploadUrl = AzurePublisherTool.CalculateInstallerUploadUrl(installerFile, Channel, version);
|
|
|
|
|
|
|
|
|
|
DebRepoPublisherTool.PublishDebFileToDebianRepo(
|
2016-04-06 22:28:12 +00:00
|
|
|
|
packageName,
|
|
|
|
|
version,
|
2016-03-23 23:37:59 +00:00
|
|
|
|
uploadUrl);
|
2016-03-22 21:14:54 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
|
|
|
|
public static BuildTargetResult PublishSharedHostDebToDebianRepo(BuildTargetContext c)
|
|
|
|
|
{
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var version = CliNuGetVersion;
|
|
|
|
|
|
2016-04-06 01:48:02 +00:00
|
|
|
|
var packageName = Monikers.GetDebianSharedHostPackageName(c);
|
2016-03-22 21:14:54 +00:00
|
|
|
|
var installerFile = c.BuildContext.Get<string>("SharedHostInstallerFile");
|
2016-03-23 23:37:59 +00:00
|
|
|
|
var uploadUrl = AzurePublisherTool.CalculateInstallerUploadUrl(installerFile, Channel, version);
|
2016-03-22 21:14:54 +00:00
|
|
|
|
|
2016-03-23 23:37:59 +00:00
|
|
|
|
DebRepoPublisherTool.PublishDebFileToDebianRepo(
|
2016-04-06 22:28:12 +00:00
|
|
|
|
packageName,
|
|
|
|
|
version,
|
2016-03-23 23:37:59 +00:00
|
|
|
|
uploadUrl);
|
2016-03-22 21:14:54 +00:00
|
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 21:39:02 +00:00
|
|
|
|
[Target]
|
|
|
|
|
[Environment("DOCKER_HUB_REPO")]
|
|
|
|
|
[Environment("DOCKER_HUB_TRIGGER_TOKEN")]
|
|
|
|
|
public static BuildTargetResult TriggerDockerHubBuilds(BuildTargetContext c)
|
|
|
|
|
{
|
|
|
|
|
string dockerHubRepo = Environment.GetEnvironmentVariable("DOCKER_HUB_REPO");
|
|
|
|
|
string dockerHubTriggerToken = Environment.GetEnvironmentVariable("DOCKER_HUB_TRIGGER_TOKEN");
|
|
|
|
|
|
|
|
|
|
Uri baseDockerHubUri = new Uri("https://registry.hub.docker.com/u/");
|
|
|
|
|
Uri dockerHubTriggerUri;
|
|
|
|
|
if (!Uri.TryCreate(baseDockerHubUri, $"{dockerHubRepo}/trigger/{dockerHubTriggerToken}/", out dockerHubTriggerUri))
|
|
|
|
|
{
|
|
|
|
|
return c.Failed("Invalid DOCKER_HUB_REPO and/or DOCKER_HUB_TRIGGER_TOKEN");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c.Info($"Triggering automated DockerHub builds for {dockerHubRepo}");
|
|
|
|
|
using (HttpClient client = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
StringContent requestContent = new StringContent("{\"build\": true}", Encoding.UTF8, "application/json");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
HttpResponseMessage response = client.PostAsync(dockerHubTriggerUri, requestContent).Result;
|
|
|
|
|
if (!response.IsSuccessStatusCode)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.AppendLine($"HTTP request to {dockerHubTriggerUri.ToString()} was unsuccessful.");
|
|
|
|
|
sb.AppendLine($"Response status code: {response.StatusCode}. Reason phrase: {response.ReasonPhrase}.");
|
|
|
|
|
sb.Append($"Respone content: {response.Content.ReadAsStringAsync().Result}");
|
|
|
|
|
return c.Failed(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (AggregateException e)
|
|
|
|
|
{
|
|
|
|
|
return c.Failed($"HTTP request to {dockerHubTriggerUri.ToString()} failed. {e.ToString()}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return c.Success();
|
|
|
|
|
}
|
2016-02-12 18:11:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|