Ejemplo n.º 1
0
        public static BuildTargetResult FinalizeBuild(BuildTargetContext c)
        {
            if (CheckIfAllBuildsHavePublished())
            {
                string targetContainer   = $"{Channel}/Binaries/Latest/";
                string targetVersionFile = $"{targetContainer}{CliNuGetVersion}";
                string semaphoreBlob     = $"{Channel}/Binaries/publishSemaphore";
                AzurePublisherTool.CreateBlobIfNotExists(semaphoreBlob);
                string leaseId = AzurePublisherTool.AcquireLeaseOnBlob(semaphoreBlob);

                // 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))
                {
                    AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
                    return(c.Success());
                }
                else
                {
                    Regex versionFileRegex = new Regex(@"(?<version>\d\.\d\.\d)-(?<release>.*)?");

                    // Delete old version files
                    AzurePublisherTool.ListBlobs($"{targetContainer}")
                    .Select(s => s.Replace("/dotnet/", ""))
                    .Where(s => versionFileRegex.IsMatch(s))
                    .ToList()
                    .ForEach(f => AzurePublisherTool.TryDeleteBlob(f));

                    // Drop the version file signaling such for any race-condition builds (see above comment).
                    AzurePublisherTool.DropLatestSpecifiedVersion(targetVersionFile);
                }

                try
                {
                    // Copy the latest CLI bits
                    CopyBlobs($"{Channel}/Binaries/{CliNuGetVersion}/", targetContainer);

                    // Copy the latest installer files
                    CopyBlobs($"{Channel}/Installers/{CliNuGetVersion}/", $"{Channel}/Installers/Latest/");

                    // Generate the 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);
                    foreach (string version in versionFiles)
                    {
                        AzurePublisherTool.PublishStringToBlob($"{Channel}/dnvm/latest.{version}", cliVersion);
                    }
                }
                finally
                {
                    AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
                }
            }

            return(c.Success());
        }
Ejemplo n.º 2
0
        public static BuildTargetResult FinalizeBuild(BuildTargetContext c)
        {
            if (CheckIfAllBuildsHavePublished())
            {
                string targetContainer   = $"{AzurePublisher.Product.Sdk}/{Channel}";
                string targetVersionFile = $"{targetContainer}/{CommitHash}";
                string semaphoreBlob     = $"{targetContainer}/publishSemaphore";
                AzurePublisherTool.CreateBlobIfNotExists(semaphoreBlob);
                string leaseId = AzurePublisherTool.AcquireLeaseOnBlob(semaphoreBlob);

                // 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))
                {
                    AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
                    return(c.Success());
                }
                else
                {
                    Regex versionFileRegex = new Regex(@"(?<CommitHash>[\w\d]{40})");

                    // Delete old version files
                    AzurePublisherTool.ListBlobs(targetContainer)
                    .Where(s => versionFileRegex.IsMatch(s))
                    .ToList()
                    .ForEach(f => AzurePublisherTool.TryDeleteBlob(f));

                    // Drop the version file signaling such for any race-condition builds (see above comment).
                    AzurePublisherTool.DropLatestSpecifiedVersion(targetVersionFile);
                }

                try
                {
                    CopyBlobsToLatest(targetContainer);

                    string cliVersion = Utils.GetCliVersionFileContent(c);
                    AzurePublisherTool.PublishStringToBlob($"{targetContainer}/latest.version", cliVersion);

                    UpdateVersionsRepo(c);
                }
                finally
                {
                    AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
                }
            }

            return(c.Success());
        }
Ejemplo n.º 3
0
        public static BuildTargetResult FinalizeBuild(BuildTargetContext c)
        {
            if (CheckIfAllBuildsHavePublished())
            {
                string targetContainer   = $"{Channel}/Binaries/Latest/";
                string targetVersionFile = $"{targetContainer}{CommitHash}";
                string semaphoreBlob     = $"{Channel}/Binaries/sharedFxPublishSemaphore";
                AzurePublisherTool.CreateBlobIfNotExists(semaphoreBlob);

                string leaseId = AzurePublisherTool.AcquireLeaseOnBlob(semaphoreBlob);

                // 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))
                {
                    AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
                    return(c.Success());
                }
                else
                {
                    Regex versionFileRegex = new Regex(@"(?<CommitHash>[\w\d]{40})");

                    // Delete old version files
                    AzurePublisherTool.ListBlobs($"{targetContainer}")
                    .Select(s => s.Replace("/dotnet/", ""))
                    .Where(s => versionFileRegex.IsMatch(s))
                    .ToList()
                    .ForEach(f => AzurePublisherTool.TryDeleteBlob(f));

                    // Drop the version file signaling such for any race-condition builds (see above comment).
                    AzurePublisherTool.DropLatestSpecifiedVersion(targetVersionFile);
                }

                try
                {
                    // Copy the shared framework + host Archives
                    CopyBlobs($"{Channel}/Binaries/{SharedFrameworkNugetVersion}/", targetContainer);

                    // Copy the shared framework installers
                    CopyBlobs($"{Channel}/Installers/{SharedFrameworkNugetVersion}/", $"{Channel}/Installers/Latest/");

                    // Copy the shared host installers
                    CopyBlobs($"{Channel}/Installers/{SharedHostNugetVersion}/", $"{Channel}/Installers/Latest/");

                    // Generate the Sharedfx Version text files
                    List <string> versionFiles = new List <string>()
                    {
                        "win.x86.version",
                        "win.x64.version",
                        "win.arm.version",
                        "win.arm64.version",
                        "linux.x64.version",
                        "ubuntu.x64.version",
                        "ubuntu.14.04.arm.version",
                        "ubuntu.16.04.x64.version",
                        "ubuntu.16.04.arm.version",
                        "ubuntu.16.10.x64.version",
                        "rhel.x64.version",
                        "osx.x64.version",
                        "debian.x64.version",
                        "centos.x64.version",
                        "fedora.23.x64.version",
                        "fedora.24.x64.version",
                        "opensuse.13.2.x64.version",
                        "opensuse.42.1.x64.version"
                    };

                    PublishCoreHostPackagesToFeed();

                    string sfxVersion = Utils.GetSharedFrameworkVersionFileContent(c);
                    foreach (string version in versionFiles)
                    {
                        AzurePublisherTool.PublishStringToBlob($"{Channel}/dnvm/latest.sharedfx.{version}", sfxVersion);
                    }
                }
                finally
                {
                    AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId);
                }
            }

            return(c.Success());
        }