Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/ModularPipelines.Build/Helpers/NugetUploadHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using EnumerableAsyncProcessor.Extensions;
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.Models;
using File = ModularPipelines.FileSystem.File;

namespace ModularPipelines.Build.Helpers;

public static class NugetUploadHelper
{
public static async Task<CommandResult[]> UploadPackagesAsync(
IModuleContext context,
IEnumerable<File> packagePaths,
string source,
string? apiKey,
CancellationToken cancellationToken)
{
return await packagePaths
.SelectAsync(async nugetFile => await context.DotNet().Nuget.Push(new DotNetNugetPushOptions
{
Path = nugetFile,
Source = source,
ApiKey = apiKey,
}, cancellationToken), cancellationToken: cancellationToken)
.ProcessOneAtATime();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using EnumerableAsyncProcessor.Extensions;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Build.Helpers;
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.Extensions;
using ModularPipelines.FileSystem;
using ModularPipelines.Models;
Expand All @@ -23,12 +20,11 @@ public class UploadPackagesToLocalNuGetModule : Module<CommandResult[]>
var localRepoLocation = context.GetModule<CreateLocalNugetFolderModule, Folder>();
var packagePaths = context.GetModule<PackagePathsParserModule, List<File>>();

return await packagePaths.Value!
.SelectAsync(async nugetFile => await context.DotNet().Nuget.Push(new DotNetNugetPushOptions
{
Path = nugetFile,
Source = localRepoLocation.Value.AssertExists(),
}, cancellationToken), cancellationToken: cancellationToken)
.ProcessOneAtATime();
return await NugetUploadHelper.UploadPackagesAsync(
context,
packagePaths.Value!,
source: localRepoLocation.Value.AssertExists()!.Path,
apiKey: null,
cancellationToken);
}
}
19 changes: 7 additions & 12 deletions src/ModularPipelines.Build/Modules/UploadPackagesToNugetModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using EnumerableAsyncProcessor.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ModularPipelines.Attributes;
using ModularPipelines.Build.Helpers;
using ModularPipelines.Build.Settings;
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.Git.Attributes;
using ModularPipelines.GitHub.Attributes;
using ModularPipelines.Models;
Expand Down Expand Up @@ -43,13 +40,11 @@ public Task<SkipDecision> ShouldSkip(IPipelineContext context)

var packagePaths = context.GetModule<PackagePathsParserModule, List<File>>();

return await packagePaths.Value!
.SelectAsync(async nugetFile => await context.DotNet().Nuget.Push(new DotNetNugetPushOptions
{
Path = nugetFile,
Source = "https://api.nuget.org/v3/index.json",
ApiKey = _nugetSettings.Value.ApiKey!,
}, cancellationToken), cancellationToken: cancellationToken)
.ProcessOneAtATime();
return await NugetUploadHelper.UploadPackagesAsync(
context,
packagePaths.Value!,
source: "https://api.nuget.org/v3/index.json",
apiKey: _nugetSettings.Value.ApiKey,
cancellationToken);
}
}
Loading