Skip to content

Commit 4e4e4a3

Browse files
darthsharpCopilot
andauthored
Add new task to cake build for publishing projects, creating dist packages and creating GitHub releases (#72)
* Upgrade `actions/checkout` in workflows to version 5 and improve logging in `CakeHostBuilder`. * Add `PublishTask` and related settings for .NET publish functionality - Introduced `PublishTask` template with `DotNetPublish` implementation. - Added `IPublishTaskSettings` and `PublishingItem` for configuring publish directory and runtime options. - Enhanced `PackTask` to remove unnecessary newline for code clarity. * Refactor task execution to use type-specific settings and add task template improvements - Updated `FrostingTaskBase` to support type-specific settings with enhanced modularity. - Refactored existing tasks (`PackTask`, `CleanTask`, `NuGetPushTask`, etc.) to replace redundant context-based setting retrieval with direct usage of task settings. - Introduced new `FrostingTaskBase<TBuildContext, TSettings>` for simplifying task development. - Added `PublishTask` default implementation and new `CreateDistPackagesTask` template for future enhancements. - Annotated relevant classes and settings with `[PublicAPI]` for improved IDE support and clarity. * Add `CreateDistPackagesTask` implementation with support for packaging in TAR.GZ and ZIP formats - Introduced `DistPackage` and `DistPackageFormat` for representing package configurations. - Added `ICreateDistPackagesTaskSettings` interface for task settings. - Updated `CreateDistPackagesTask` to handle packaging logic based on configurable formats. - Included necessary project references to `CreativeCoders.IO`. * Migrate `CreativeCoders.IO.Archives` and `CreativeCoders.IO.Ports` into separate projects with refactored architecture - Removed `CreativeCoders.IO` project and reorganized its contents. - Introduced new `CreativeCoders.IO.Archives` project with abstractions for TAR/ZIP archive handling. - Added `CreativeCoders.IO.Ports` project for serial port functionalities. - Updated package references and dependencies to align with the new modular structure. - Enhanced service registration with dependency injection extensions for archives. * Use `Ensure.NotNull` for null validation in archive classes - Updated constructors in `ZipArchiveWriter`, `ZipArchiveReader`, `TarArchiveWriter`, `TarArchiveReader`, and `TarGzArchiveReader` to use `Ensure.NotNull` for null validation. - Improved code clarity and standardized null handling across archive operations. * - Refactor `FrostingTaskBase` to enable skipping tasks without settings via the new `SkipIfNoSettings` property. - Update `CreateDistPackagesTask` to use `IArchiveWriterFactory` for TAR.GZ and ZIP packaging. - Simplify `DefaultHostSetup` to summarize task and version setup during execution. - Fix incorrect `ProjectReference` paths in `CreativeCoders.CakeBuild.csproj`. - Enhance dependency injection for `IFileSystem` to use `IFileSystemEx`. - Add `PublicAPI` annotations to improve IDE support across tasks and settings. * Enhance TAR/ZIP archive handling with `IFileSystem` integration and `copyData` support in `OpenEntryStreamAsync` * Remove redundant `ProjectReference` to `CreativeCoders.IO` in unit test project. * Add unit test files and exclude `ArchiveWriterFactory` from code coverage - Added placeholder unit test classes and test files for `TarArchiveWriter`. - Excluded `ArchiveWriterFactory` from code coverage analysis with `[ExcludeFromCodeCoverage]`. * Update test file inclusion in `CreativeCoders.IO.UnitTests.csproj` - Mark `TestSource01.html` and `TestText01.txt` as content items instead of none. * Add comprehensive unit tests for `TarArchiveWriter` and introduce new cleanup utilities - Added tests for various TAR archive creation operations, including files, streams, directories, and metadata configuration. - Updated `TarArchiveWriter` to support `leaveOpen` behavior through its constructor. - Introduced `FileCleanUp` and `DirectoryCleanUp` utilities for temporary resource cleanup in tests. * Remove unused test files and update project file accordingly in `CreativeCoders.IO.UnitTests` * Add comprehensive unit tests for `ZipArchiveWriter` and update `leaveOpen` support - Introduced unit tests covering file, stream, directory operations, and compression level handling in `ZipArchiveWriter`. - Updated `ZipArchiveWriter`, `IZipArchiveWriterFactory`, `ZipArchiveWriterFactory`, and related methods to support `leaveOpen` behavior. - Added `TarEntryInfo` class and minor updates to existing file handling logic to improve consistency. - Updated `.gitignore` to exclude `.ai-plans`. * Exclude `Dispose` methods in `ZipArchiveWriter` and `TarArchiveWriter` from code coverage analysis * Add comprehensive unit tests for `TarArchiveReader` and improve file extraction handling - Introduced tests covering archive entry listing, stream opening, single file extraction, and full archive extraction in `TarArchiveReader`. - Updated `ExtractFileCoreAsync` to reset entry streams before reading and improve support for `IFileSystem`. - Modified `OpenEntryStreamAsync` to ensure memory stream positioning before returning. * Integrate `IFileSystem` into `ZipArchiveReader` and `ZipArchiveReaderFactory` - Refactored both classes to support dependency injection with `IFileSystem`. - Updated file handling methods to use `IFileSystem` abstractions, improving testability and flexibility. - Adjusted relevant `Create` and `CreateAsync` methods to include optional `IFileSystem` parameters. * Add unit tests for `ZipArchiveReader` and enhance cleanup utilities - Introduced comprehensive tests for `ZipArchiveReader`, covering entry listing, stream handling, and file extraction scenarios. - Updated `FileCleanUp` and `DirectoryCleanUp` to include existence checks before deletion to prevent unnecessary exceptions. * Exclude `Dispose` methods in `ZipArchiveReader` and `TarArchiveReader` from code coverage * Fix path construction in `ZipArchiveReaderTests` to use `Path.Combine` for cross-platform compatibility * Improve path handling in `ZipArchiveReaderTests` by using `Path.Combine` for cross-platform consistency * Add GitHub release creation logic and utilities - Introduced `CreateGitHubReleaseTask` for automated GitHub release creation with draft support. - Added `GitHubReleaseAsset` and `GitHubReleaseFileAsset` to manage release assets and file streams. - Integrated `MimeMapping` and `Octokit` for MIME type handling and GitHub API interactions. - Updated project file to include necessary package references for `MimeMapping` and `Octokit`. * Refactor GitHub release task to use `IGitHubClientFactory` for improved token handling and flexibility * Integrate `IFileSystem` abstraction into archive writer factories and extend Cake tasks - Added `IFileSystem` dependency to `ZipArchiveWriterFactory` and `TarArchiveWriterFactory` to improve testability and directory handling. - Enhanced Cake build system with `ICreateDistPackagesTaskSettings` and integrated `PublishTask`, `CreateDistPackagesTask`, and `CreateGitHubReleaseTask`. - Updated `CakeHostExtensions` to include default services and new task configurations. * Use constant `CliHostSampleAppProjectName` for improved maintainability in path construction. * Use `_fileSystem` abstraction in `ZipArchiveWriterFactory` to improve testability and consistency * Add unit tests for `ArchiveWriterFactory` to validate writer creation logic - Introduced tests for creating tar, tar.gz, and zip writers with both streams and filenames. - Validated integration of `ITarArchiveWriterFactory` and `IZipArchiveWriterFactory` in writer creation methods. * Add project for `CreativeCoders.CakeBuild.Tests` and integrate it into the solution * Remove `<TargetFramework>` property from test project files for cleanup and consistency * Add unit tests for Tar and Zip archive reader and writer factories - Introduced `TarArchiveReaderFactoryTests` and `TarArchiveWriterFactoryTests` to validate creating readers and writers for `.tar` and `.tar.gz` formats using streams and filenames. - Added `ZipArchiveReaderFactoryTests` and `ZipArchiveWriterFactoryTests` to ensure proper behavior of `.zip` archive reader and writer creation methods. * Make `ExtendedAttributes` property immutable by changing it to `init` accessor * Make `ExtendedAttributes` property mutable by changing accessor from `init` to `set` * Add unit tests for Cake build task templates - Introduced tests for various task templates, including `BuildTask`, `CleanTask`, `CodeCoverageTask`, `CreateDistPackagesTask`, `CreateGitHubReleaseTask`, `NuGetPushTask`, `PackTask`, `PublishTask`, `RestoreTask`, and `TestTask`. - Added `CakeTestHelper` for mock context and filesystem setup. - Updated test project with new dependencies and project references. * Refactor and enhance Cake build tasks and unit tests - Updated and enhanced existing unit tests for all main Cake build tasks (`BuildTask`, `CleanTask`, `CodeCoverageTask`, `CreateDistPackagesTask`, `CreateGitHubReleaseTask`, `NuGetPushTask`, `PackTask`, `PublishTask`, `RestoreTask`, and `TestTask`) to ensure stricter validation and better assertions. - Replaced test assertions with `AwesomeAssertions` for improved readability and accuracy. - Renamed property `DistFolder` to `SourceFolder` and updated related logic in `DistPackage` class. - Adjusted mock setups across test cases to align with intended execution flows for all tasks. - Fixed and streamlined test invocation logic to better capture process interaction and directory handling. * Make `OpenEntryStreamAsync` in `ZipArchiveReader` support copying data to a memory stream - Refactored `OpenEntryStreamAsync` to allow copying entry data into a `MemoryStream` when `copyData` is set to `true`. - Improved error handling and asynchronous stream operations for better reliability. * Add unit tests for `TarGzArchiveReader` and enhance `OpenEntryStreamAsync` behavior in archive readers - Introduced comprehensive unit tests for `TarGzArchiveReader` to validate archive entry listing, stream opening, and file extraction behavior. - Updated `OpenEntryStreamAsync` in both `TarGzArchiveReader` and `ZipArchiveReader` to reset `MemoryStream` position after data copy for reliable usage. - Refactored `ZipArchiveWriterTests` to simplify stream handling in `AddFileAsync`. * Refactor `CreateGitHubReleaseTask` to simplify stream handling and improve `UploadAsset` usage * Add `PathSafety` utility for path validation and integrate it into archive readers - Introduced `PathSafety` class to validate paths and prevent path traversal attacks. - Added `PathSafetyTests` for comprehensive unit testing of path validation methods. - Updated archive readers (`ZipArchiveReader`, `TarArchiveReader`, and `TarGzArchiveReader`) to enforce path safety checks during file extraction. - Enhanced `PathExtensions` with `IsSafe` and `EnsureSafe` extension methods for convenient usage. * Improve path handling in archive readers and enhance GZip file extension checks - Corrected parameter order in `EnsureSafe` usage within `ZipArchiveReader`. - Updated `ArchiveEntry` to use `FileSys.Path` for path operations, improving consistency. - Enhanced `TarFileHelper.IsGZipFile` to fix incorrect extension logic and handle `.tar.gz` files. * Update source/CakeBuild/CreativeCoders.CakeBuild/Tasks/Templates/Settings/ICreateGitHubReleaseTaskSettings.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update source/CakeBuild/CreativeCoders.CakeBuild/Tasks/Templates/CreateGitHubReleaseTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add nullability annotations and enhance `CreateGitHubReleaseTask` tests - Enabled nullable annotations in `PathSafety`. - Added a test for `CreateGitHubReleaseTask` to validate behavior when no GitHub token is provided. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4c4ea75 commit 4e4e4a3

107 files changed

Lines changed: 3974 additions & 615 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
TERM: xterm
6262
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
6363
steps:
64-
- uses: actions/checkout@v4
64+
- uses: actions/checkout@v5
6565
with:
6666
fetch-depth: 0
6767
- name: 'Cache: ~/.nuget/packages'

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
TERM: xterm
1414
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
with:
1818
fetch-depth: 0
1919
- name: 'Cache: ~/.nuget/packages'
@@ -38,7 +38,7 @@ jobs:
3838
TERM: xterm
3939
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
4040
steps:
41-
- uses: actions/checkout@v4
41+
- uses: actions/checkout@v5
4242
with:
4343
fetch-depth: 0
4444
- name: 'Cache: ~/.nuget/packages'
@@ -61,7 +61,7 @@ jobs:
6161
TERM: xterm
6262
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
6363
steps:
64-
- uses: actions/checkout@v4
64+
- uses: actions/checkout@v5
6565
with:
6666
fetch-depth: 0
6767
- name: 'Cache: ~/.nuget/packages'

.github/workflows/pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
TERM: xterm
1414
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
with:
1818
fetch-depth: 0
1919
- name: 'Cache: ~/.nuget/packages'
@@ -36,7 +36,7 @@ jobs:
3636
TERM: xterm
3737
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
3838
steps:
39-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v5
4040
with:
4141
fetch-depth: 0
4242
- name: 'Cache: ~/.nuget/packages'
@@ -59,7 +59,7 @@ jobs:
5959
TERM: xterm
6060
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
6161
steps:
62-
- uses: actions/checkout@v4
62+
- uses: actions/checkout@v5
6363
with:
6464
fetch-depth: 0
6565
- name: 'Cache: ~/.nuget/packages'

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
TERM: xterm
1414
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
with:
1818
fetch-depth: 0
1919
- name: 'Cache: ~/.nuget/packages'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,5 @@ ASALocalRun/
328328
.nuke
329329

330330
.DS_Store
331+
332+
.ai-plans

Core.sln

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.Daemon.Windo
147147
EndProject
148148
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IO", "IO", "{F31389F0-613B-48B1-AA99-6BFC3D8D7D1A}"
149149
EndProject
150-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.IO", "source\IO\CreativeCoders.IO\CreativeCoders.IO.csproj", "{3B1E60AF-5B5C-4BED-8AAF-79167CF5E2C0}"
151-
EndProject
152150
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.Net.JsonRpc", "source\Net\CreativeCoders.Net.JsonRpc\CreativeCoders.Net.JsonRpc.csproj", "{0D77E6F7-5D76-4DF0-BE57-BA459951CD2F}"
153151
EndProject
154152
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NoSql", "NoSql", "{F708D571-2BF4-4F2D-9711-B00D245A0BB3}"
@@ -258,6 +256,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ci", "ci", "{F3331DB3-C40A-
258256
EndProject
259257
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "build\Build.csproj", "{4A397E49-CB4F-4348-9798-A7F2B5F276DA}"
260258
EndProject
259+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.IO.Archives", "source\IO\CreativeCoders.IO.Archives\CreativeCoders.IO.Archives.csproj", "{EC120660-306E-4E48-8FBB-43D9F3962CEE}"
260+
EndProject
261+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.IO.Ports", "source\IO\CreativeCoders.IO.Ports\CreativeCoders.IO.Ports.csproj", "{C34426F1-E40C-498D-8FDE-D4ECEB3E49D4}"
262+
EndProject
263+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.CakeBuild.Tests", "tests\CreativeCoders.CakeBuild.Tests\CreativeCoders.CakeBuild.Tests.csproj", "{A081DDB3-A9DB-498F-824B-C605ACFDB43A}"
264+
EndProject
261265
Global
262266
GlobalSection(SolutionConfigurationPlatforms) = preSolution
263267
Debug|Any CPU = Debug|Any CPU
@@ -428,10 +432,6 @@ Global
428432
{30E75E1A-146F-422E-8C14-3AE0F7FB99B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
429433
{30E75E1A-146F-422E-8C14-3AE0F7FB99B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
430434
{30E75E1A-146F-422E-8C14-3AE0F7FB99B1}.Release|Any CPU.Build.0 = Release|Any CPU
431-
{3B1E60AF-5B5C-4BED-8AAF-79167CF5E2C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
432-
{3B1E60AF-5B5C-4BED-8AAF-79167CF5E2C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
433-
{3B1E60AF-5B5C-4BED-8AAF-79167CF5E2C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
434-
{3B1E60AF-5B5C-4BED-8AAF-79167CF5E2C0}.Release|Any CPU.Build.0 = Release|Any CPU
435435
{0D77E6F7-5D76-4DF0-BE57-BA459951CD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
436436
{0D77E6F7-5D76-4DF0-BE57-BA459951CD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
437437
{0D77E6F7-5D76-4DF0-BE57-BA459951CD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -576,6 +576,18 @@ Global
576576
{58C01CB8-B65A-44FE-9BE0-22929CD474A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
577577
{4A397E49-CB4F-4348-9798-A7F2B5F276DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
578578
{4A397E49-CB4F-4348-9798-A7F2B5F276DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
579+
{EC120660-306E-4E48-8FBB-43D9F3962CEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
580+
{EC120660-306E-4E48-8FBB-43D9F3962CEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
581+
{EC120660-306E-4E48-8FBB-43D9F3962CEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
582+
{EC120660-306E-4E48-8FBB-43D9F3962CEE}.Release|Any CPU.Build.0 = Release|Any CPU
583+
{C34426F1-E40C-498D-8FDE-D4ECEB3E49D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
584+
{C34426F1-E40C-498D-8FDE-D4ECEB3E49D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
585+
{C34426F1-E40C-498D-8FDE-D4ECEB3E49D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
586+
{C34426F1-E40C-498D-8FDE-D4ECEB3E49D4}.Release|Any CPU.Build.0 = Release|Any CPU
587+
{A081DDB3-A9DB-498F-824B-C605ACFDB43A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
588+
{A081DDB3-A9DB-498F-824B-C605ACFDB43A}.Debug|Any CPU.Build.0 = Debug|Any CPU
589+
{A081DDB3-A9DB-498F-824B-C605ACFDB43A}.Release|Any CPU.ActiveCfg = Release|Any CPU
590+
{A081DDB3-A9DB-498F-824B-C605ACFDB43A}.Release|Any CPU.Build.0 = Release|Any CPU
579591
EndGlobalSection
580592
GlobalSection(SolutionProperties) = preSolution
581593
HideSolutionNode = FALSE
@@ -637,7 +649,6 @@ Global
637649
{74B31A58-28CB-4B90-B2A4-C64F339FC93D} = {99FFD9AA-7AEB-4A9D-881D-00B7277C3494}
638650
{30E75E1A-146F-422E-8C14-3AE0F7FB99B1} = {99FFD9AA-7AEB-4A9D-881D-00B7277C3494}
639651
{F31389F0-613B-48B1-AA99-6BFC3D8D7D1A} = {2A7105AA-05B6-469A-93F5-719723A4D90D}
640-
{3B1E60AF-5B5C-4BED-8AAF-79167CF5E2C0} = {F31389F0-613B-48B1-AA99-6BFC3D8D7D1A}
641652
{0D77E6F7-5D76-4DF0-BE57-BA459951CD2F} = {354E69EA-9EA1-4F7E-A3C2-372DFB259C35}
642653
{F708D571-2BF4-4F2D-9711-B00D245A0BB3} = {D913C0D3-85B9-4E89-82D6-8371FB6C99E7}
643654
{E6D5CE84-542C-4125-B094-D8C67A11AF13} = {F708D571-2BF4-4F2D-9711-B00D245A0BB3}
@@ -684,6 +695,9 @@ Global
684695
{58C01CB8-B65A-44FE-9BE0-22929CD474A2} = {72E179CA-7AE6-412A-856D-7BD13838E8E3}
685696
{F3331DB3-C40A-4712-A545-EE5C628B0F39} = {92288F2D-DE57-4018-855B-BD7F2344265F}
686697
{4A397E49-CB4F-4348-9798-A7F2B5F276DA} = {DB7A40EE-F469-4B87-A629-250BBB9ECC92}
698+
{EC120660-306E-4E48-8FBB-43D9F3962CEE} = {F31389F0-613B-48B1-AA99-6BFC3D8D7D1A}
699+
{C34426F1-E40C-498D-8FDE-D4ECEB3E49D4} = {F31389F0-613B-48B1-AA99-6BFC3D8D7D1A}
700+
{A081DDB3-A9DB-498F-824B-C605ACFDB43A} = {5A3FFD14-2258-4007-AC77-BAFB3B3EB26F}
687701
EndGlobalSection
688702
GlobalSection(ExtensibilityGlobals) = postSolution
689703
SolutionGuid = {EE24476B-9A4C-4146-B982-3461FAF8B3B0}

samples/CakeBuildSample/SampleBuildContext.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
namespace CakeBuildSample;
1212

1313
[UsedImplicitly]
14-
public class SampleBuildContext(ICakeContext context) : CakeBuildContext(context), IDefaultTaskSettings
14+
public class SampleBuildContext(ICakeContext context)
15+
: CakeBuildContext(context), IDefaultTaskSettings, ICreateDistPackagesTaskSettings
1516
{
1617
public IList<DirectoryPath> DirectoriesToClean => this.CastAs<ICleanTaskSettings>()
1718
.GetDefaultDirectoriesToClean().AddRange(RootDir.Combine(".tests"));
@@ -30,4 +31,30 @@ public class SampleBuildContext(ICakeContext context) : CakeBuildContext(context
3031
public bool SkipPush => this.BuildSystem().IsPullRequest ||
3132
this.BuildSystem().IsLocalBuild ||
3233
this.GitHubActions().Environment.Runner.OS != "Linux";
34+
35+
public DirectoryPath PublishOutputDir => ArtifactsDir.Combine("publish");
36+
37+
private const string CliHostSampleAppProjectName = "CliHostSampleApp";
38+
39+
public IEnumerable<PublishingItem> PublishingItems =>
40+
[
41+
new PublishingItem(
42+
RootDir.Combine("samples").Combine(CliHostSampleAppProjectName)
43+
.CombineWithFilePath("CliHostSampleApp.csproj"),
44+
PublishOutputDir.Combine(CliHostSampleAppProjectName))
45+
];
46+
47+
public IEnumerable<DistPackage> DistPackages =>
48+
[
49+
new DistPackage("clihostsample", PublishOutputDir.Combine(CliHostSampleAppProjectName))
50+
{
51+
Format = DistPackageFormat.TarGz
52+
},
53+
new DistPackage("clihostsample", PublishOutputDir.Combine(CliHostSampleAppProjectName))
54+
{
55+
Format = DistPackageFormat.Zip
56+
}
57+
];
58+
59+
public DirectoryPath DistOutputPath => ArtifactsDir.Combine("dist");
3360
}

source/CakeBuild/CreativeCoders.CakeBuild/CakeHostBuilder.cs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using Cake.Common.Diagnostics;
21
using Cake.Core;
32
using Cake.Frosting;
4-
using CreativeCoders.CakeBuild.Tasks.Templates.Settings;
53
using CreativeCoders.Core;
64
using CreativeCoders.Core.IO;
7-
using JetBrains.Annotations;
5+
using Microsoft.Extensions.DependencyInjection;
86

97
namespace CreativeCoders.CakeBuild;
108

@@ -93,36 +91,3 @@ public CakeHost Build()
9391
return _cakeHost;
9492
}
9593
}
96-
97-
[UsedImplicitly]
98-
public class DefaultHostSetup : IFrostingSetup
99-
{
100-
public void Setup(ICakeContext context, ISetupContext info)
101-
{
102-
if (context is not CakeBuildContext buildContext)
103-
{
104-
return;
105-
}
106-
107-
if (!buildContext.PrintSetupSummary)
108-
{
109-
return;
110-
}
111-
112-
var pushSettings = buildContext.GetSettings<INuGetPushTaskSettings>();
113-
114-
if (pushSettings != null)
115-
{
116-
context.Information($"Skip Push: {pushSettings.SkipPush}");
117-
}
118-
119-
var version = buildContext.Version;
120-
121-
context.Information("Version Info");
122-
123-
context.Information($"Informational Version: {version.InformationalVersion}");
124-
context.Information($"Assembly Version: {version.AssemblySemVer}");
125-
context.Information($"File Version: {version.AssemblySemFileVer}");
126-
context.Information($"Package Version: {version.SemVer}");
127-
}
128-
}

source/CakeBuild/CreativeCoders.CakeBuild/CakeHostExtensions.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System.Reflection;
22
using Cake.Frosting;
33
using CreativeCoders.CakeBuild.BuildServer;
4+
using CreativeCoders.CakeBuild.GitHub;
45
using CreativeCoders.CakeBuild.Tasks.Defaults;
56
using CreativeCoders.CakeBuild.Tasks.Templates.Settings;
7+
using CreativeCoders.IO.Archives;
68
using JetBrains.Annotations;
79
using Microsoft.Extensions.DependencyInjection;
810
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -58,13 +60,21 @@ public static CakeHost AddTasks(this CakeHost host, params Type[] taskTypes)
5860
public static CakeHost AddDefaultTasks(this CakeHost host)
5961
{
6062
return host.AddTasks(
61-
typeof(CleanTask),
62-
typeof(RestoreTask),
63-
typeof(BuildTask),
64-
typeof(TestTask),
65-
typeof(CodeCoverageTask),
66-
typeof(PackTask),
67-
typeof(NuGetPushTask));
63+
typeof(CleanTask),
64+
typeof(RestoreTask),
65+
typeof(BuildTask),
66+
typeof(TestTask),
67+
typeof(CodeCoverageTask),
68+
typeof(PackTask),
69+
typeof(NuGetPushTask),
70+
typeof(PublishTask),
71+
typeof(CreateDistPackagesTask),
72+
typeof(CreateGitHubReleaseTask))
73+
.ConfigureServices(x =>
74+
{
75+
x.AddArchives();
76+
x.TryAddSingleton<IGitHubClientFactory, GitHubClientFactory>();
77+
});
6878
}
6979

7080
public static CakeHost AddBuildServerIntegration(this CakeHost host)
@@ -74,15 +84,6 @@ public static CakeHost AddBuildServerIntegration(this CakeHost host)
7484
.UseTaskTeardown<EndGroupTaskTeardown>();
7585
}
7686

77-
public static CakeHost SetupHost<TBuildContext, TBuildSetup>(this CakeHost host)
78-
where TBuildSetup : class
79-
where TBuildContext : CakeBuildContext
80-
{
81-
return host
82-
.UseContext<TBuildContext>()
83-
.UseBuildSetup<TBuildSetup>();
84-
}
85-
8687
public static CakeHost UseBuildSetup<TBuildSetup>(this CakeHost host)
8788
where TBuildSetup : class
8889
{

source/CakeBuild/CreativeCoders.CakeBuild/CreativeCoders.CakeBuild.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Cake.Frosting" Version="6.0.0"/>
11+
<PackageReference Include="MimeMapping" Version="3.1.0"/>
12+
<PackageReference Include="Octokit" Version="14.0.0"/>
1113
</ItemGroup>
1214

1315
<ItemGroup>
1416
<ProjectReference Include="..\..\Core\CreativeCoders.Core\CreativeCoders.Core.csproj"/>
17+
<ProjectReference Include="..\..\IO\CreativeCoders.IO.Archives\CreativeCoders.IO.Archives.csproj"/>
1518
</ItemGroup>
1619

1720
</Project>

0 commit comments

Comments
 (0)