From 1ea776d8a5b084998fce87873f2ea5591d9b9d88 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Wed, 6 Jan 2021 19:36:08 -0800 Subject: [PATCH 1/4] Publish to multiple channels --- eng/promote-build.yml | 2 +- src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs | 3 ++- .../src/PublishArtifactsInManifest.cs | 2 +- .../src/PublishArtifactsInManifestV3.cs | 2 +- .../src/common/AzureStorageUtils.cs | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/eng/promote-build.yml b/eng/promote-build.yml index cfe64e8df5e..49584685e8f 100644 --- a/eng/promote-build.yml +++ b/eng/promote-build.yml @@ -89,7 +89,7 @@ stages: exit 1 } - $channels = ${Env:PromoteToChannelIds} -split "," + $channels = ${Env:PromoteToChannelIds} -split "-" foreach ($channelId in $channels) { $channelApiEndpoint = "$(MaestroApiEndPoint)/api/channels/${channelId}?api-version=$(MaestroApiVersion)" $channelInfo = try { Invoke-WebRequest -Method Get -Uri $channelApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs index 0c907bd0c71..0d5c1bd3cb6 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs @@ -190,8 +190,9 @@ public async Task UploadAssetAsync( } else { + FileStream stream = new FileStream(item.ItemSpec, FileMode.Open, FileAccess.Read, FileShare.Read); Log.LogMessage($"Uploading {item} to {relativeBlobPath}."); - await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath); + await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath, stream); } } catch (Exception exc) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs index 24774eb8c93..7559ff755b7 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs @@ -231,7 +231,7 @@ public async Task ExecuteAsync() IMaestroApi client = ApiFactory.GetAuthenticated(MaestroApiEndpoint, BuildAssetRegistryToken); Maestro.Client.Models.Build buildInformation = await client.Builds.GetBuildAsync(BARBuildId); - var targetChannelsIds = TargetChannels.Split(',').Select(ci => int.Parse(ci)); + var targetChannelsIds = TargetChannels.Split('-').Select(ci => int.Parse(ci)); foreach (var targetChannelId in targetChannelsIds) { diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestV3.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestV3.cs index fa41af41e54..9d56f4438f6 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestV3.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestV3.cs @@ -69,7 +69,7 @@ public override async Task ExecuteAsync() { List targetChannelsIds = new List(); - foreach (var channelIdStr in TargetChannels.Split(',')) + foreach (var channelIdStr in TargetChannels.Split('-')) { if (!int.TryParse(channelIdStr, out var channelId)) { diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs index 664a0a810a4..f582c5e3498 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/common/AzureStorageUtils.cs @@ -61,7 +61,7 @@ public static string CalculateMD5(string filename) } } - public async Task UploadBlockBlobAsync(string filePath, string blobPath) + public async Task UploadBlockBlobAsync(string filePath, string blobPath, Stream stream) { BlobClient blob = GetBlob(blobPath.Replace("\\", "/")); BlobHttpHeaders headers = GetBlobHeadersByExtension(filePath); @@ -83,7 +83,7 @@ public async Task UploadBlockBlobAsync(string filePath, string blobPath) try { await blob.UploadAsync( - filePath, + stream, headers) .ConfigureAwait(false); return true; From 173ff7deba7f840128b2d40461c7ad2040f186be Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Fri, 8 Jan 2021 17:48:51 -0800 Subject: [PATCH 2/4] minor fix --- eng/common/post-build/publish-using-darc.ps1 | 2 +- .../src/BlobFeedAction.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1 index 6b68ee84728..789d942fbbb 100644 --- a/eng/common/post-build/publish-using-darc.ps1 +++ b/eng/common/post-build/publish-using-darc.ps1 @@ -17,7 +17,7 @@ param( try { . $PSScriptRoot\post-build-utils.ps1 # Hard coding darc version till the next arcade-services roll out, cos this version has required API changes for darc add-build-to-channel - $darc = Get-Darc "1.1.0-beta.20418.1" + $darc = Get-Darc "1.1.0-beta.21058.3" $optionalParams = [System.Collections.ArrayList]::new() diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs index 0d5c1bd3cb6..77d64e62215 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs @@ -190,9 +190,12 @@ public async Task UploadAssetAsync( } else { - FileStream stream = new FileStream(item.ItemSpec, FileMode.Open, FileAccess.Read, FileShare.Read); - Log.LogMessage($"Uploading {item} to {relativeBlobPath}."); - await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath, stream); + using (FileStream stream = + new FileStream(item.ItemSpec, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + Log.LogMessage($"Uploading {item} to {relativeBlobPath}."); + await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath, stream); + } } } catch (Exception exc) From bd767c21e2a0477dffd872bcc521253d1cedfe9a Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 14 Jan 2021 14:10:18 -0800 Subject: [PATCH 3/4] latest darc version --- eng/common/post-build/publish-using-darc.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1 index 789d942fbbb..1a11fe65c47 100644 --- a/eng/common/post-build/publish-using-darc.ps1 +++ b/eng/common/post-build/publish-using-darc.ps1 @@ -16,8 +16,7 @@ param( try { . $PSScriptRoot\post-build-utils.ps1 - # Hard coding darc version till the next arcade-services roll out, cos this version has required API changes for darc add-build-to-channel - $darc = Get-Darc "1.1.0-beta.21058.3" + . $PSScriptRoot\..\darc-init.ps1 $optionalParams = [System.Collections.ArrayList]::new() @@ -56,7 +55,7 @@ try { } } - & $darc add-build-to-channel ` + & darc add-build-to-channel ` --id $buildId ` --publishing-infra-version $PublishingInfraVersion ` --default-channels ` From 6ee9f1bba9c51bf9c2effe3607261731330115cf Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 14 Jan 2021 15:02:04 -0800 Subject: [PATCH 4/4] darc version --- eng/common/post-build/publish-using-darc.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1 index 1a11fe65c47..599a1172419 100644 --- a/eng/common/post-build/publish-using-darc.ps1 +++ b/eng/common/post-build/publish-using-darc.ps1 @@ -16,7 +16,8 @@ param( try { . $PSScriptRoot\post-build-utils.ps1 - . $PSScriptRoot\..\darc-init.ps1 + + $darc = Get-Darc $optionalParams = [System.Collections.ArrayList]::new() @@ -55,7 +56,7 @@ try { } } - & darc add-build-to-channel ` + & $darc add-build-to-channel ` --id $buildId ` --publishing-infra-version $PublishingInfraVersion ` --default-channels `