diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0513212 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,19 @@ +name: Pure.DI check + +on: [ push, pull_request ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Build + run: dotnet run --project ./Build diff --git a/Build/Program.cs b/Build/Program.cs index 51a25e1..c4278d0 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -37,24 +37,18 @@ ("version", nuGetVersion.ToString()) }; - new DotNetClean() - .WithConfiguration(configuration) - .WithProps(props) - .Build() - .Succeed(); - - new DotNetTest() - .WithConfiguration(configuration) - .WithProps(props) - .Build() - .Succeed(); - - new DotNetPack() - .WithConfiguration(configuration) - .WithNoBuild(true) - .WithProps(props) - .Build() - .Succeed(); + Assertion.Succeed( + new DotNetTest() + .WithConfiguration(configuration) + .WithProps(props) + .Build()); + + Assertion.Succeed( + new DotNetPack() + .WithConfiguration(configuration) + .WithNoBuild(true) + .WithProps(props) + .Build()); packages.Add(Path.Combine(output, $"roslyn{@case.AnalyzerRoslynVersion}", $"Immutype.{nuGetVersion}.nupkg")); } @@ -68,12 +62,13 @@ if (!string.IsNullOrWhiteSpace(apiKey) && nuGetVersion.Release != "dev") { - new DotNetNuGetPush() - .WithApiKey(apiKey) - .WithSources("https://api.nuget.org/v3/index.json") - .WithPackage(package) - .Run(). - Succeed($"Pushing {Path.GetFileName(package)}"); + Assertion.Succeed( + new DotNetNuGetPush() + .WithApiKey(apiKey) + .WithSources("https://api.nuget.org/v3/index.json") + .WithPackage(package) + .Run(), + $"Pushing {Path.GetFileName(package)}"); } WriteLine($"Package version: {nuGetVersion}", Color.Highlighted); diff --git a/Build/Tools.cs b/Build/Tools.cs index 66ec324..bd46ed8 100644 --- a/Build/Tools.cs +++ b/Build/Tools.cs @@ -102,7 +102,7 @@ public static string Get(string name, string defaultProp, bool showWarning = fal static class Assertion { - public static bool Succeed(this int? exitCode, string shortName) + public static bool Succeed(int? exitCode, string shortName) { if (exitCode == 0) { @@ -114,7 +114,7 @@ public static bool Succeed(this int? exitCode, string shortName) return false; } - public static async Task Succeed(this Task exitCodeTask, string shortName) => + public static async Task Succeed(Task exitCodeTask, string shortName) => Succeed(await exitCodeTask, shortName); private static bool CheckBuildResult(IBuildResult result) @@ -136,7 +136,7 @@ select testResult.ToString()) return false; } - public static void Succeed(this IBuildResult result) + public static void Succeed(IBuildResult result) { if (!CheckBuildResult(result)) { @@ -144,7 +144,7 @@ public static void Succeed(this IBuildResult result) } } - public static async Task Succeed(this Task resultTask) + public static async Task Succeed(Task resultTask) { if (CheckBuildResult(await resultTask)) {