Logicality.GitHub.Actions.Workflow
0.6.0
dotnet add package Logicality.GitHub.Actions.Workflow --version 0.6.0
NuGet\Install-Package Logicality.GitHub.Actions.Workflow -Version 0.6.0
<PackageReference Include="Logicality.GitHub.Actions.Workflow" Version="0.6.0" />
<PackageVersion Include="Logicality.GitHub.Actions.Workflow" Version="0.6.0" />
<PackageReference Include="Logicality.GitHub.Actions.Workflow" />
paket add Logicality.GitHub.Actions.Workflow --version 0.6.0
#r "nuget: Logicality.GitHub.Actions.Workflow, 0.6.0"
#addin nuget:?package=Logicality.GitHub.Actions.Workflow&version=0.6.0
#tool nuget:?package=Logicality.GitHub.Actions.Workflow&version=0.6.0
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- YamlDotNet (>= 16.3.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 (1)
Showing the top 1 popular GitHub repositories that depend on Logicality.GitHub.Actions.Workflow:
Repository | Stars |
---|---|
DuendeSoftware/products
The most flexible and standards-compliant OpenID Connect and OAuth 2.x framework for ASP.NET Core
|
Version | Downloads | Last updated |
---|---|---|
0.6.0 | 1,390 | a month ago |
0.5.1 | 2,999 | 6 months ago |
0.5.0 | 61 | 6 months ago |
0.4.0 | 53 | 6 months ago |
0.3.0 | 164 | 12/5/2022 |
0.2.7 | 1,087 | 8/9/2022 |
0.2.6 | 125 | 8/6/2022 |
0.2.5 | 133 | 5/14/2022 |
0.2.4 | 112 | 5/14/2022 |
0.2.3 | 112 | 5/14/2022 |
0.2.2 | 112 | 5/14/2022 |
0.2.1 | 109 | 5/14/2022 |
0.2.0 | 129 | 4/20/2022 |
See https://github.com/logicality-io/platform-libs/releases for release notes.