diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5ad737f..5c1a649 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,47 +2,37 @@ name: CI build
on:
push:
- branches: [ master, develop ]
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Setup .NET Core 3.1
- uses: actions/setup-dotnet@v2
- with:
- dotnet-version: 3.1.x
-
- - name: Setup .NET 6.0
- uses: actions/setup-dotnet@v2
- with:
- dotnet-version: 6.0.x
-
- - name: Restore dependencies
- working-directory: ./src
- run: dotnet restore
-
- - name: Build
- working-directory: ./src
- run: dotnet build -c Release --no-restore
-
- - name: List NuGet packages
- working-directory: ./src
- run: find . \( -name "*.nupkg" -o -name "*.snupkg" \) -type f
-
- - name: Upload NuGet packages
- uses: actions/upload-artifact@v3
- with:
- name: nuget-packages
- path: |
- ./src/GSoft.Extensions.Configuration.Substitution/bin/Release/*.nupkg
- ./src/GSoft.Extensions.Configuration.Substitution/bin/Release/*.snupkg
-
- - name: Test
- working-directory: ./src
- run: dotnet test -c Release --no-build --verbosity normal
\ No newline at end of file
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Setup .NET Core 3.1
+ uses: actions/setup-dotnet@v2
+ with:
+ dotnet-version: 3.1.x
+
+ - name: Setup .NET 6.0
+ uses: actions/setup-dotnet@v2
+ with:
+ dotnet-version: 6.0.x
+
+ - name: Cake build
+ run: chmod +x ./build.sh && ./build.sh --target=Pack
+ shell: bash
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@v3
+ with:
+ name: packages
+ path: ./.output/**/*
diff --git a/.github/workflows/nuget-push.yml b/.github/workflows/nuget-push.yml
index d78043c..53fac8e 100644
--- a/.github/workflows/nuget-push.yml
+++ b/.github/workflows/nuget-push.yml
@@ -1,47 +1,35 @@
name: NuGet push
on:
- workflow_dispatch:
+ push:
+ tags:
+ - "*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Setup .NET Core 3.1
- uses: actions/setup-dotnet@v2
- with:
- dotnet-version: 3.1.x
-
- - name: Setup .NET 6.0
- uses: actions/setup-dotnet@v2
- with:
- dotnet-version: 6.0.x
-
- - name: Remove outdated Nuget packages
- working-directory: ./src
- run: find . \( -name "*.nupkg" -o -name "*.snupkg" \) -type f -delete
-
- - name: Restore dependencies
- working-directory: ./src
- run: dotnet restore
-
- - name: Build
- working-directory: ./src
- run: dotnet build -c Release --no-restore
-
- - name: Test
- working-directory: ./src
- run: dotnet test -c Release --no-build --verbosity normal
-
- - name: Rename NuGet packages
- working-directory: ./src/GSoft.Extensions.Configuration.Substitution/bin/Release
- run: mv *.nupkg GSoft.Extensions.Configuration.Substitution.nupkg && mv *.snupkg GSoft.Extensions.Configuration.Substitution.snupkg
-
- - name: Push NuGet packages
- working-directory: ./src/GSoft.Extensions.Configuration.Substitution/bin/Release
- run: dotnet nuget push GSoft.Extensions.Configuration.Substitution.nupkg --api-key ${{ secrets.nuget_api_key }} --source https://api.nuget.org/v3/index.json
\ No newline at end of file
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Setup .NET Core 3.1
+ uses: actions/setup-dotnet@v2
+ with:
+ dotnet-version: 3.1.x
+
+ - name: Setup .NET 6.0
+ uses: actions/setup-dotnet@v2
+ with:
+ dotnet-version: 6.0.x
+
+ - name: Cake build
+ run: chmod +x ./build.sh && ./build.sh --target=Push --nuget-api-key=${{ secrets.nuget_api_key }} --nuget-source=${{ secrets.nuget_source }}
+ shell: bash
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@v3
+ with:
+ name: packages
+ path: ./.output/**/*
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 6707e64..febdc5a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -384,4 +384,8 @@ FodyWeavers.xsd
Desktop.ini
ehthumbs.db
Thumbs.db
-$RECYCLE.BIN/
\ No newline at end of file
+$RECYCLE.BIN/
+
+# Cake
+build/tools/**
+!build/tools/packages.config
\ No newline at end of file
diff --git a/build.ps1 b/build.ps1
new file mode 100644
index 0000000..a707719
--- /dev/null
+++ b/build.ps1
@@ -0,0 +1,2 @@
+dotnet run --project build/Build.csproj -- $args
+exit $LASTEXITCODE;
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..dfd6b85
--- /dev/null
+++ b/build.sh
@@ -0,0 +1 @@
+dotnet run --project ./build/Build.csproj -- "$@"
diff --git a/build/Build.csproj b/build/Build.csproj
new file mode 100644
index 0000000..c66d32e
--- /dev/null
+++ b/build/Build.csproj
@@ -0,0 +1,14 @@
+
+
+ Exe
+ net6.0
+ $(MSBuildProjectDirectory)
+ True
+ enable
+ 10
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/Program.cs b/build/Program.cs
new file mode 100644
index 0000000..85be5eb
--- /dev/null
+++ b/build/Program.cs
@@ -0,0 +1,180 @@
+using System;
+using System.IO;
+using Cake.Common;
+using Cake.Common.IO;
+using Cake.Common.Tools.DotNet;
+using Cake.Common.Tools.DotNet.Build;
+using Cake.Common.Tools.DotNet.MSBuild;
+using Cake.Common.Tools.DotNet.NuGet.Push;
+using Cake.Common.Tools.DotNet.Pack;
+using Cake.Common.Tools.DotNet.Restore;
+using Cake.Common.Tools.DotNet.Test;
+using Cake.Common.Tools.GitVersion;
+using Cake.Core;
+using Cake.Core.Diagnostics;
+using Cake.Frosting;
+
+return new CakeHost()
+ .InstallTool(new Uri("dotnet:?package=GitVersion.Tool&version=5.10.1"))
+ .UseContext()
+ .Run(args);
+
+public static class Constants
+{
+ public const string Release = "Release";
+ public const string ProjectName = "GSoft.Extensions.Configuration.Substitution";
+
+ public static readonly string SourceDirectoryPath = Path.Combine("..", "src");
+ public static readonly string OutputDirectoryPath = Path.Combine("..", ".output");
+ public static readonly string SolutionPath = Path.Combine(SourceDirectoryPath, ProjectName + ".sln");
+ public static readonly string MainProjectPath = Path.Combine(SourceDirectoryPath, ProjectName, ProjectName + ".csproj");
+}
+
+public class BuildContext : FrostingContext
+{
+ public BuildContext(ICakeContext context) : base(context)
+ {
+ this.NugetApiKey = context.Argument("nuget-api-key", string.Empty);
+ this.NugetSource = context.Argument("nuget-source", string.Empty);
+ }
+
+ public DotNetMSBuildSettings MSBuildSettings { get; } = new DotNetMSBuildSettings();
+
+ public string NugetApiKey { get; }
+
+ public string NugetSource { get; }
+
+ public void AddMSBuildSetting(string name, string value, bool log = false)
+ {
+ if (log)
+ {
+ this.Log.Information(name + ": " + value);
+ }
+
+ if (!string.IsNullOrWhiteSpace(value))
+ {
+ this.MSBuildSettings.Properties[name] = new[] { value };
+ }
+ }
+}
+
+[TaskName("Clean")]
+public sealed class CleanTask : FrostingTask
+{
+ public override void Run(BuildContext context)
+ {
+ var objGlobPath = Path.Combine(Constants.SourceDirectoryPath, "*", "obj");
+ var binGlobPath = Path.Combine(Constants.SourceDirectoryPath, "*", "bin");
+
+ context.CleanDirectories(Constants.OutputDirectoryPath);
+ context.CleanDirectories(objGlobPath);
+ context.CleanDirectories(binGlobPath);
+ }
+}
+
+[TaskName("GitVersion")]
+public sealed class GitVersionTask : FrostingTask
+{
+ public override void Run(BuildContext context)
+ {
+ var gitVersion = context.GitVersion();
+
+ context.AddMSBuildSetting("Version", gitVersion.NuGetVersion, log: true);
+ context.AddMSBuildSetting("VersionPrefix", gitVersion.MajorMinorPatch, log: true);
+ context.AddMSBuildSetting("VersionSuffix", gitVersion.PreReleaseTag, log: true);
+ context.AddMSBuildSetting("PackageVersion", gitVersion.FullSemVer, log: true);
+ context.AddMSBuildSetting("InformationalVersion", gitVersion.InformationalVersion, log: true);
+ context.AddMSBuildSetting("AssemblyVersion", gitVersion.AssemblySemVer, log: true);
+ context.AddMSBuildSetting("FileVersion", gitVersion.AssemblySemFileVer, log: true);
+ context.AddMSBuildSetting("RepositoryBranch", gitVersion.BranchName, log: true);
+ context.AddMSBuildSetting("RepositoryCommit", gitVersion.Sha, log: true);
+ }
+}
+
+[TaskName("Restore")]
+[IsDependentOn(typeof(CleanTask))]
+[IsDependentOn(typeof(GitVersionTask))]
+public sealed class RestoreTask : FrostingTask
+{
+ public override void Run(BuildContext context) => context.DotNetRestore(Constants.SolutionPath, new DotNetRestoreSettings
+ {
+ MSBuildSettings = context.MSBuildSettings,
+ });
+}
+
+[TaskName("Build")]
+[IsDependentOn(typeof(RestoreTask))]
+public sealed class BuildTask : FrostingTask
+{
+ public override void Run(BuildContext context)
+ {
+ context.AddMSBuildSetting("Deterministic", "true");
+ context.AddMSBuildSetting("ContinuousIntegrationBuild", "true");
+
+ context.DotNetBuild(Constants.SolutionPath, new DotNetBuildSettings
+ {
+ Configuration = Constants.Release,
+ MSBuildSettings = context.MSBuildSettings,
+ NoRestore = true,
+ NoLogo = true,
+ });
+ }
+}
+
+[TaskName("Test")]
+[IsDependentOn(typeof(BuildTask))]
+public sealed class TestTask : FrostingTask
+{
+ public override void Run(BuildContext context)
+ {
+ foreach (var testProjectFilePath in context.GetFiles(Path.Combine(Constants.SourceDirectoryPath, "*", "*.Tests.csproj")))
+ {
+ context.DotNetTest(testProjectFilePath.FullPath, new DotNetTestSettings
+ {
+ Configuration = Constants.Release,
+ Loggers = new[] { "console;verbosity=detailed" },
+ NoBuild = true,
+ NoLogo = true,
+ });
+ }
+ }
+}
+
+[TaskName("Pack")]
+[IsDependentOn(typeof(TestTask))]
+public sealed class PackTask : FrostingTask
+{
+ public override void Run(BuildContext context) => context.DotNetPack(Constants.MainProjectPath, new DotNetPackSettings
+ {
+ Configuration = Constants.Release,
+ MSBuildSettings = context.MSBuildSettings,
+ OutputDirectory = Constants.OutputDirectoryPath,
+ NoBuild = true,
+ NoRestore = true,
+ NoLogo = true,
+ });
+}
+
+[TaskName("Push")]
+[IsDependentOn(typeof(PackTask))]
+public sealed class PushTask : FrostingTask
+{
+ public override void Run(BuildContext context)
+ {
+ foreach (var packageFilePath in context.GetFiles(Path.Combine(Constants.OutputDirectoryPath, "*.nupkg")))
+ {
+ context.DotNetNuGetPush(packageFilePath, new DotNetNuGetPushSettings
+ {
+ ApiKey = context.NugetApiKey,
+ Source = context.NugetSource,
+ IgnoreSymbols = false
+ });
+ }
+ }
+}
+
+[TaskName("Default")]
+[IsDependentOn(typeof(PackTask))]
+public sealed class DefaultTask : FrostingTask
+{
+}
\ No newline at end of file
diff --git a/src/GSoft.Extensions.Configuration.Substitution.snk b/src/GSoft.Extensions.Configuration.Substitution.snk
new file mode 100644
index 0000000..0311fea
Binary files /dev/null and b/src/GSoft.Extensions.Configuration.Substitution.snk differ
diff --git a/src/GSoft.Extensions.Configuration.Substitution/GSoft.Extensions.Configuration.Substitution.csproj b/src/GSoft.Extensions.Configuration.Substitution/GSoft.Extensions.Configuration.Substitution.csproj
index 6d3789f..8e93820 100644
--- a/src/GSoft.Extensions.Configuration.Substitution/GSoft.Extensions.Configuration.Substitution.csproj
+++ b/src/GSoft.Extensions.Configuration.Substitution/GSoft.Extensions.Configuration.Substitution.csproj
@@ -6,17 +6,12 @@
snupkg
GSoft.Extensions.Configuration.Substitution
GSoft.Extensions.Configuration.Substitution
-
-
-
- true
+ true
+ true
+ ../GSoft.Extensions.Configuration.Substitution.snk
-
- All
-
-