Home

Awesome

ModularPipelines

Define your pipeline in .NET! Strong types, intellisense, parallelisation, and the entire .NET ecosystem at your fingertips.

nuget

Nuget GitHub Workflow Status (with event) GitHub last commit (branch) Codacy Badge CodeFactor License Codacy Badge codecov

Documentation

https://thomhurst.github.io/ModularPipelines

Features

Available Modules

PackageDescriptionVersion
ModularPipelinesWrite your pipelines in C#!nuget
ModularPipelines.AmazonWebServicesHelpers for interacting with Amazon Web Services.nuget
ModularPipelines.AzureHelpers for interacting with Azure.nuget
ModularPipelines.Azure.PipelinesHelpers for interacting with Azure Pipeline agents.nuget
ModularPipelines.ChocolateyHelpers for interacting with the Chocolatey CLI.nuget
ModularPipelines.CmdHelpers for interacting with the Windows cmd process.nuget
ModularPipelines.DockerHelpers for interacting with the Docker CLI.nuget
ModularPipelines.DotNetHelpers for interacting with dotnet CLI.nuget
ModularPipelines.EmailHelpers for sending emails.nuget
ModularPipelines.FtpHelpers for downloading and uploading via FTP.nuget
ModularPipelines.GitHelpers for interacting with git.nuget
ModularPipelines.GitHubHelpers for interacting with GitHub Actions build agents.nuget
ModularPipelines.GoogleHelpers for interacting with the Google gcloud CLI.nuget
ModularPipelines.HelmHelpers for interacting with Helm CLI.nuget
ModularPipelines.KubernetesHelpers for interacting with kubectl CLI.nuget
ModularPipelines.MicrosoftTeamsHelpers for sending Microsoft Teams cards.nuget
ModularPipelines.NodeHelpers for interacting with node / npm CLI.nuget
ModularPipelines.SlackHelpers for sending Slack cards.nuget
ModularPipelines.TeamCityHelpers for interacting with TeamCity build agents.nuget
ModularPipelines.TerraformHelpers for interacting with Terraform CLI.nuget
ModularPipelines.WinGetHelpers for interacting with the Windows Package Manager.nuget
ModularPipelines.YarnHelpers for interacting with Yarn CLI.nuget

Getting Started

If you want to see how to get started, or want to know more about ModularPipelines, read the Documentation here

Console Progress

image

Results

<img width="444" alt="image" src="https://github.com/thomhurst/ModularPipelines/assets/30480171/8963e891-2c29-4382-9a3e-6ced4daf4d4b">

How does this compare to Cake / Nuke

Code Examples

Program.cs - Main method

await PipelineHostBuilder.Create()
    .ConfigureAppConfiguration((context, builder) =>
    {
        builder.AddJsonFile("appsettings.json")
            .AddUserSecrets<Program>()
            .AddEnvironmentVariables();
    })
    .ConfigureServices((context, collection) =>
    {
        collection.Configure<NuGetSettings>(context.Configuration.GetSection("NuGet"));
        collection.Configure<PublishSettings>(context.Configuration.GetSection("Publish"));
        collection.AddSingleton<ISomeService1, SomeService1>();
        collection.AddTransient<ISomeService2, SomeService2>();
    })
    .AddModule<FindNugetPackagesModule>()
    .AddModule<UploadNugetPackagesModule>()
    .ExecutePipelineAsync();

Custom Modules

public class FindNugetPackagesModule : Module<FileInfo>
{
    protected override Task<List<File>?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
    {
        return context.Git()
            .RootDirectory
            .GetFiles(path => path.Extension is ".nupkg")
            .ToList()
            .AsTask();
    }
}
[DependsOn<FindNugetPackagesModule>]
public class UploadNugetPackagesModule : Module<FileInfo>
{
    private readonly IOptions<NuGetSettings> _nugetSettings;

    public UploadNugetPackagesModule(IOptions<NuGetSettings> nugetSettings)
    {
        _nugetSettings = nugetSettings;
    }

    protected override async Task<CommandResult?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
    {
        var nugetFiles = await GetModule<FindNugetPackagesModule>();

        return await nugetFiles.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();
    }
}

Breaking changes

While I will try to limit breaking changes, there may be some changes within minor versions. These will be noted on release notes.