auto create channel

This commit is contained in:
Caelan Sayler
2024-12-24 14:57:59 +00:00
committed by Caelan
parent 120aba3a2a
commit b00183b03e

View File

@@ -196,6 +196,8 @@ public class VelopackFlowServiceClient(
$"Creating release {version}", $"Creating release {version}",
async (report) => { async (report) => {
report(-1); report(-1);
await CreateChannelIfNotExists(packageId, channel, cancellationToken);
report(50);
var result = await CreateReleaseGroupAsync(packageId, version, channel, cancellationToken); var result = await CreateReleaseGroupAsync(packageId, version, channel, cancellationToken);
report(100); report(100);
return result; return result;
@@ -312,6 +314,16 @@ public class VelopackFlowServiceClient(
Logger.LogWarning("Release did not go live within 5 minutes (timeout)."); Logger.LogWarning("Release did not go live within 5 minutes (timeout).");
} }
private async Task CreateChannelIfNotExists(string packageId, string channel, CancellationToken cancellationToken)
{
var request = new CreateChannelRequest() {
PackageId = packageId,
Name = channel,
};
var client = GetFlowApi();
await client.CreateChannelAsync(request, cancellationToken);
}
private async Task<ReleaseGroup> CreateReleaseGroupAsync(string packageId, SemanticVersion version, string channel, CancellationToken cancellationToken) private async Task<ReleaseGroup> CreateReleaseGroupAsync(string packageId, SemanticVersion version, string channel, CancellationToken cancellationToken)
{ {
CreateReleaseGroupRequest request = new() { CreateReleaseGroupRequest request = new() {