Logicality.GitHub.Actions.Workflow
0.5.1
dotnet add package Logicality.GitHub.Actions.Workflow --version 0.5.1
NuGet\Install-Package Logicality.GitHub.Actions.Workflow -Version 0.5.1
<PackageReference Include="Logicality.GitHub.Actions.Workflow" Version="0.5.1" />
paket add Logicality.GitHub.Actions.Workflow --version 0.5.1
#r "nuget: Logicality.GitHub.Actions.Workflow, 0.5.1"
// Install Logicality.GitHub.Actions.Workflow as a Cake Addin #addin nuget:?package=Logicality.GitHub.Actions.Workflow&version=0.5.1 // Install Logicality.GitHub.Actions.Workflow as a Cake Tool #tool nuget:?package=Logicality.GitHub.Actions.Workflow&version=0.5.1
GitHub Actions Workflow
Introduction
A library to help generate GitHub Actions Workflows yaml in a fluent manner. Written to support a better authoring experience, increase reusability (distributable as a NuGet package) and mitigates against the fragility of copy'n'pasting stuff around. If one is maintaining just a few simple workflows this is probably over-kill. If one is maintaining many workflows across many repositories where one wants to be able to to reuse standardised jobs and steps, then this may be useful.
Simple Example
The following code:
var workflow = new Workflow("my-workflow");
workflow.On
.Push()
.Branches("main")
var buildJob = workflow
.Job("build")
.RunsOn(GitHubHostedRunner.UbuntuLatest);
buildJob.Step()
.ActionsCheckout(); // Via extensions package
buildJob.Step()
.Name("Build")
.Run($"./build.ps1")
.Shell(Shells.PowerShell);
workflow.WriteYaml("../workflows/my-workflow.yml", yaml);
... will generate the following yaml:
name: my-workflow
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build
run: ./build.ps1
shell: pwsh
See WorkflowGen in this repository for a more comprehensive example.
Using
Create a new console project
WorkflowGen
(or what ever you want call it). I recommend putting in the ./github/ directory.dotnet new console --name WorkflowGen
Add the necessary package reference:
cd WorkflowGen dotnet add package Logicality.GitHub.Actions.Workflow --prerelease
Add some workflow generating code:
using Logicality.GitHub.Actions.Workflow; var workflow = new Workflow("my-workflow"); workflow.On .Push() .Branches("main"); // Workflow path relative to console project workflow.WriteYaml("../workflows/my-workflow.yaml");
Generate the workflow:
dotnet run
Re-generate the workflow when ever you make changes by calling
dotnet run
The API should be discoverable if one is familiar with GitHub Workflow Syntax. This project is not a substitute for understanding and learning the syntax.
Contributing
- Open a discussion if any questions, feedback or requests.
- Open an issue if there are any bugs with a full reproducible.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- YamlDotNet (>= 15.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Logicality.GitHub.Actions.Workflow:
Package | Downloads |
---|---|
Logicality.GitHub.Actions.Workflow.Extensions
A collection of extensions and common steps and jobs for GitHub Actions Workflow library. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.5.1 | 139 | 11/12/2024 |
0.5.0 | 51 | 11/5/2024 |
0.4.0 | 45 | 11/3/2024 |
0.3.0 | 146 | 12/5/2022 |
0.2.7 | 1,072 | 8/9/2022 |
0.2.6 | 116 | 8/6/2022 |
0.2.5 | 124 | 5/14/2022 |
0.2.4 | 103 | 5/14/2022 |
0.2.3 | 103 | 5/14/2022 |
0.2.2 | 103 | 5/14/2022 |
0.2.1 | 99 | 5/14/2022 |
0.2.0 | 120 | 4/20/2022 |
0.1.0 | 115 | 4/19/2022 |
0.1.0-alpha.0 | 58 | 12/5/2022 |
See https://github.com/logicality-io/platform-libs/releases for release notes.