Skip to content

Commit

Permalink
Publish to multiple channels - Part 2 (dotnet#6754)
Browse files Browse the repository at this point in the history
* Publish to multiple channels
  • Loading branch information
epananth authored and akoeplinger committed Apr 12, 2021
1 parent d6e07e4 commit 9138f6e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions eng/common/post-build/publish-using-darc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ 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

$optionalParams = [System.Collections.ArrayList]::new()

Expand Down
2 changes: 1 addition & 1 deletion eng/promote-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: $_" }
Expand Down
8 changes: 6 additions & 2 deletions src/Microsoft.DotNet.Build.Tasks.Feed/src/BlobFeedAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ public async Task UploadAssetAsync(
}
else
{
Log.LogMessage($"Uploading {item} to {relativeBlobPath}.");
await blobUtils.UploadBlockBlobAsync(item.ItemSpec, relativeBlobPath);
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public async Task<bool> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override async Task<bool> ExecuteAsync()
{
List<int> targetChannelsIds = new List<int>();

foreach (var channelIdStr in TargetChannels.Split(','))
foreach (var channelIdStr in TargetChannels.Split('-'))
{
if (!int.TryParse(channelIdStr, out var channelId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -83,7 +83,7 @@ public async Task UploadBlockBlobAsync(string filePath, string blobPath)
try
{
await blob.UploadAsync(
filePath,
stream,
headers)
.ConfigureAwait(false);
return true;
Expand Down

0 comments on commit 9138f6e

Please sign in to comment.