From f3b7bb88193b89a77d08d585df23a2d61ca4d7b8 Mon Sep 17 00:00:00 2001 From: Scott Bilas Date: Sun, 1 Dec 2024 16:47:30 +0000 Subject: [PATCH] Start supporting OkTools.Terminal as a package --- .../{publish.yml => publish-core.yml} | 2 +- .github/workflows/publish-terminal.yml | 33 +++++++++++++++++++ Directory.Packages.props | 1 + OkTools-Working.sln | 9 +++++ src/Core/PUBLISHING.md => PUBLISHING.md | 12 ++++--- pre-publish.ps1 | 27 +++++++++++++++ src/Core/README.md | 3 ++ src/Terminal/README.md | 3 ++ targets/Library.targets | 5 +-- 9 files changed, 88 insertions(+), 7 deletions(-) rename .github/workflows/{publish.yml => publish-core.yml} (96%) create mode 100644 .github/workflows/publish-terminal.yml rename src/Core/PUBLISHING.md => PUBLISHING.md (59%) create mode 100644 pre-publish.ps1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish-core.yml similarity index 96% rename from .github/workflows/publish.yml rename to .github/workflows/publish-core.yml index 7328e48..44d9823 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish-core.yml @@ -3,7 +3,7 @@ name: Publish NuGet Package on: workflow_dispatch: push: - tags: [ release-* ] + tags: [ release-core-* ] # TODO: trigger on commit desc '/publish' # TODO: switch to https://github.com/xoofx/dotnet-releaser diff --git a/.github/workflows/publish-terminal.yml b/.github/workflows/publish-terminal.yml new file mode 100644 index 0000000..9d2f21b --- /dev/null +++ b/.github/workflows/publish-terminal.yml @@ -0,0 +1,33 @@ +name: Publish NuGet Package + +on: + workflow_dispatch: + push: + tags: [ release-terminal-* ] + +# TODO: trigger on commit desc '/publish' +# TODO: switch to https://github.com/xoofx/dotnet-releaser + +jobs: + publish: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Setup .NET + uses: actions/setup-dotnet@v4.1.0 + with: + dotnet-version: 8.0.x + + - name: Run tests + run: | + dotnet test --nologo -l:"console;verbosity=normal" src\Terminal\Terminal-Tests.csproj -c Release + + - name: Pack nuget + run: dotnet pack src\Terminal\Terminal.csproj -c Release + + - name: Publish NuGet package + run: | + dotnet nuget push publish\Terminal\*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json diff --git a/Directory.Packages.props b/Directory.Packages.props index 41f085a..0742422 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,6 +15,7 @@ + diff --git a/OkTools-Working.sln b/OkTools-Working.sln index 58069d7..c4cc4dd 100644 --- a/OkTools-Working.sln +++ b/OkTools-Working.sln @@ -34,6 +34,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terminal", "src\Terminal\Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terminal-Tests", "src\Terminal\Terminal-Tests.csproj", "{CB4C57D5-478F-4066-BC7A-2C2F42F36109}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageLibs", "PackageLibs", "{9E9A15D4-3B6A-44C8-A056-8D7A6960D042}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -109,4 +111,11 @@ Global {CB4C57D5-478F-4066-BC7A-2C2F42F36109}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB4C57D5-478F-4066-BC7A-2C2F42F36109}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C30F4B4B-DDBB-4D66-A7C0-6C71637CEC39} = {9E9A15D4-3B6A-44C8-A056-8D7A6960D042} + {C778A428-E82E-4364-970E-5F1655233BF5} = {9E9A15D4-3B6A-44C8-A056-8D7A6960D042} + {3D70F5C9-4AA8-4B3F-AB87-E23B8F6B7507} = {9E9A15D4-3B6A-44C8-A056-8D7A6960D042} + {D6D04E0D-8325-4BDF-B4E8-2CBFF54764DE} = {9E9A15D4-3B6A-44C8-A056-8D7A6960D042} + {CB4C57D5-478F-4066-BC7A-2C2F42F36109} = {9E9A15D4-3B6A-44C8-A056-8D7A6960D042} + EndGlobalSection EndGlobal diff --git a/src/Core/PUBLISHING.md b/PUBLISHING.md similarity index 59% rename from src/Core/PUBLISHING.md rename to PUBLISHING.md index be29534..c3c8fa5 100644 --- a/src/Core/PUBLISHING.md +++ b/PUBLISHING.md @@ -1,13 +1,17 @@ -# Publishing OkTools.Core +# Publishing -Do this: +## OkTools.Core * Edit `Core.csproj` and bump the `PackageVersion` -* `dotnet build src/Core/Core.csproj --nologo -c Release && dotnet test src/Core/Core-Tests.csproj --nologo` +* Run `pre-publish.ps1 -Core` to build and test. * Send it to GitHub * `git commit/reset` and get to a clean state * `git push`, wait for https://github.com/scottbilas/OkTools/actions to be green (this runs the "Validate Dev Branch" action) - * `git tag release-$version` where `$version` is what was set in the .csproj above + * `git tag release-core-$version` where `$version` is what was set in the .csproj above * `git push --tags` (this runs the "Publish NuGet Package" action) If there are no errors, publishing the new version to the Nuget Gallery should happen in about 5 minutes. + +## OkTools.Terminal + +Same as OkTools.Core except replace Core with Terminal and use tag release-terminal-$version. diff --git a/pre-publish.ps1 b/pre-publish.ps1 new file mode 100644 index 0000000..81a5c12 --- /dev/null +++ b/pre-publish.ps1 @@ -0,0 +1,27 @@ +[CmdletBinding()] +param ( + [switch]$Core, + [switch]$Terminal) + +$rc = 0 + +if ($Core) { + "*** BUILDING CORE ***" + dotnet build src/Core/Core.csproj -c Release --nologo + if (!$LASTEXITCODE) { + dotnet test src/Core/Core-Tests.csproj --nologo + } + if ($LASTEXITCODE) { $rc = 1 } + "" +} + +if ($Terminal) { + dotnet build src/Terminal/Terminal.csproj -c Release --nologo + if (!$LASTEXITCODE) { + dotnet test src/Terminal/Terminal-Tests.csproj --nologo + } + if ($LASTEXITCODE) { $rc = 1 } + "" +} + +exit $rc diff --git a/src/Core/README.md b/src/Core/README.md index 00a57d3..da73c20 100644 --- a/src/Core/README.md +++ b/src/Core/README.md @@ -1,3 +1,6 @@ # OkTools.Core Some OK core utilities. + +Important: I'm not yet following semver or worrying about API breakage. Every +single release is potentially breaking. diff --git a/src/Terminal/README.md b/src/Terminal/README.md index a65b767..dcce8f1 100644 --- a/src/Terminal/README.md +++ b/src/Terminal/README.md @@ -1,3 +1,6 @@ # OkTools.Terminal Some OK utilities for the terminal. + +Important: I'm not yet following semver or worrying about API breakage. Every +single release is potentially breaking. diff --git a/targets/Library.targets b/targets/Library.targets index 5fd0c50..cc35a84 100644 --- a/targets/Library.targets +++ b/targets/Library.targets @@ -66,10 +66,11 @@ net8.0;net9.0 - + - + +