-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from pleonex/feature/small-fixes
🐛 Small fixes and improvements
- Loading branch information
Showing
13 changed files
with
211 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,80 @@ | ||
# PleOps Cake | ||
# PleOps Cake ![logo](./images/logo_48.png) | ||
|
||
<!-- markdownlint-disable MD033 --> | ||
<p align="center"> | ||
<a href="https://www.nuget.org/packages/Cake.Frosting.PleOps.Recipe"> | ||
<img alt="Stable version" src="https://img.shields.io/nuget/v/Cake.Frosting.PleOps.Recipe?label=nuget.org&logo=nuget" /> | ||
</a> | ||
| ||
<a href="https://dev.azure.com/benito356/NetDevOpsTest/_packaging?_a=feed&feed=PleOps"> | ||
<img alt="GitHub commits since latest release (by SemVer)" src="https://img.shields.io/github/commits-since/pleonex/PleOps.Cake/latest?sort=semver" /> | ||
</a> | ||
| ||
<a href="https://github.com/pleonex/PleOps.Cake/workflows/Build%20and%20release"> | ||
<img alt="Build and release" src="https://github.com/pleonex/PleOps.Cake/workflows/Build%20and%20release/badge.svg?branch=main&event=push" /> | ||
</a> | ||
| ||
<a href="https://choosealicense.com/licenses/mit/"> | ||
<img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat" /> | ||
</a> | ||
| ||
</p> | ||
|
||
Complete DevOps workflow and best-practices for .NET projects based on | ||
[Cake](https://cakebuild.net/). | ||
|
||
- ♻️ DevOps best practices for a software project | ||
- 🔧 Build, test and release tasks for .NET projects and documentation sites | ||
- 📚 Documentation explaining the workflow | ||
- [Template repository](https://github.com/pleonex/template-csharp) ready to use | ||
- 📋 [Template repository](https://github.com/pleonex/template-csharp) ready to | ||
use | ||
|
||
## Tech stack | ||
|
||
- Projects: C# / .NET | ||
- Documentation: DocFX, GitHub page | ||
- CI: GitHub Actions | ||
- Release deployment: NuGet feeds, GitHub | ||
- **Projects**: C# / .NET | ||
- **Documentation**: DocFX, GitHub page | ||
- **CI**: GitHub Actions | ||
- **Release deployment**: NuGet feeds, GitHub | ||
|
||
## Usage | ||
|
||
The project ships a NuGet library with [Cake Frosting](https://cakebuild.net/) | ||
tasks: **`Cake.Frosting.PleOps.Recipe`**. | ||
tasks: | ||
|
||
- `Cake.Frosting.PleOps.Recipe`: | ||
![Package in NuGet](https://img.shields.io/nuget/v/Cake.Frosting.PleOps.Recipe?label=nuget.org&logo=nuget) | ||
|
||
To use it, create a new console application with the | ||
[_Cake Frosting_ template](https://cakebuild.net/docs/getting-started/setting-up-a-new-frosting-project), | ||
add a reference to this recipe NuGet and its tasks will be available to use. | ||
|
||
**More information in the | ||
[setup guide](./articles/getting-started/tutorial.md).** | ||
```cs | ||
return new CakeHost() | ||
.AddAssembly(typeof(Cake.Frosting.PleOps.Recipe.PleOpsBuildContext).Assembly) | ||
.UseContext<Cake.Frosting.PleOps.Recipe.PleOpsBuildContext>() | ||
.UseLifetime<BuildLifetime>() | ||
.Run(args); | ||
|
||
## Quick demo | ||
[TaskName("Default")] | ||
[IsDependentOn(typeof(Cake.Frosting.PleOps.Recipe.Common.SetGitVersionTask))] | ||
[IsDependentOn(typeof(Cake.Frosting.PleOps.Recipe.Common.CleanArtifactsTask))] | ||
[IsDependentOn(typeof(Cake.Frosting.PleOps.Recipe.Dotnet.DotnetTasks.BuildProjectTask))] | ||
public sealed class DefaultTask : FrostingTask | ||
{ | ||
} | ||
``` | ||
|
||
You can check this workflow from the | ||
[template repository](https://github.com/pleonex/template-csharp). Just clone / | ||
download it and run its build system: | ||
Then just run the project to start the build system: | ||
|
||
```bash | ||
# Build and run tests (with code coverage!) | ||
dotnet run --project build/orchestrator | ||
|
||
# Create bundles (nuget, zips, docs) | ||
dotnet run --project build/orchestrator -- --target=Bundle | ||
``` | ||
|
||
Commits will trigger a new continuous integration build with a similar output as | ||
this: | ||
Pushing commits will trigger a new continuous integration build with a similar | ||
output as this: | ||
|
||
![ci-output](./articles/getting-started/images/github-actions-summary.png) | ||
|
||
> [!TIP] | ||
> Find a detailed setup guide in the | ||
> [documentation site](articles/getting-started/tutorial.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Cake.Frosting.PleOps.Recipe/CakeArgumentsExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2023 Benito Palacios Sánchez | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
namespace Cake.Frosting.PleOps.Recipe; | ||
|
||
using Cake.Core; | ||
|
||
/// <summary> | ||
/// Extension methods for ICakeArguments class. | ||
/// </summary> | ||
public static class CakeArgumentsExtensions | ||
{ | ||
/// <summary> | ||
/// Run the setter if the argument name is present. | ||
/// </summary> | ||
/// <param name="handler">Cake argument handler.</param> | ||
/// <param name="argName">Argument name.</param> | ||
/// <param name="setter">Setter to run.</param> | ||
public static void SetIfPresent(this ICakeArguments handler, string argName, Action<string> setter) | ||
{ | ||
if (handler.HasArgument(argName)) { | ||
setter(handler.GetArgument(argName)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Run the setter if the argument name is present. | ||
/// </summary> | ||
/// <param name="handler">Cake argument handler.</param> | ||
/// <param name="argName">Argument name.</param> | ||
/// <param name="setter">Setter to run.</param> | ||
public static void SetIfPresent(this ICakeArguments handler, string argName, Action<bool> setter) | ||
{ | ||
if (handler.HasArgument(argName)) { | ||
string valueText = handler.GetArgument(argName); | ||
if (string.IsNullOrEmpty(valueText)) { | ||
// If it's present but without value, assume is like a set -> true | ||
setter(true); | ||
} else { | ||
bool value = bool.Parse(handler.GetArgument(argName)); | ||
setter(value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.