Skip to content

Commit

Permalink
Start supporting OkTools.Terminal as a package
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbilas committed Dec 1, 2024
1 parent 76c2bc1 commit f3b7bb8
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/publish-terminal.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- name: Setup .NET
uses: actions/[email protected]
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
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.3.6" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta" /> <!-- need this older version for netstandard, i haven't figured out the issue yet -->
<PackageVersion Include="OkTools.Core" Version="1.0.18" />
<PackageVersion Include="OkTools.NiceIO" Version="1.0.10" />
<PackageVersion Include="PInvoke.Kernel32" Version="0.7.124" />
<PackageVersion Include="PInvoke.NTDll" Version="0.7.124" />
Expand Down
9 changes: 9 additions & 0 deletions OkTools-Working.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
12 changes: 8 additions & 4 deletions src/Core/PUBLISHING.md → PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 27 additions & 0 deletions pre-publish.ps1
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions src/Core/README.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions src/Terminal/README.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 3 additions & 2 deletions targets/Library.targets
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<!-- Feature: Core -->
<!-- Feature: Core(Package) -->

<ItemGroup Condition=" $(OkFeatures.Contains(';Core;')) ">
<ProjectReference Include="$(OkSrcRoot)Core\Core.csproj" />
<ProjectReference Include="$(OkSrcRoot)Core\Core.csproj" Condition=" '$(_IsPublishing)' != 'true' " />
<PackageReference Include="OkTools.Core" Condition=" '$(_IsPublishing)' == 'true' " />
<Using Include="OkTools.Core" />
<Using Include="OkTools.Core.Extensions" />
<Using Include="OkTools.Core.StaticUtility" Static="true" />
Expand Down

0 comments on commit f3b7bb8

Please sign in to comment.