automatically update readme example versions when packing nuget

This commit is contained in:
Caelan Sayler
2022-01-24 23:39:54 +00:00
parent 91b2cf585f
commit 243c4191c6
2 changed files with 13 additions and 3 deletions

View File

@@ -94,8 +94,8 @@ Windows apps should be as fast and as easy to install and update as apps like Go
5. Create a Squirrel release using the `Squirrel.exe` command line tool.
The tool can be downloaded from GitHub Releases, and it is also bundled into the [Clowd.Squirrel](https://www.nuget.org/packages/Clowd.Squirrel/) nuget package.
If installed through NuGet, the tools can usually be found at:
- `%userprofile%\.nuget\packages\Clowd.Squirrel\<Clowd.Squirrel version>\tools`, or;
- `..\packages\Clowd.Squirrel\<Clowd.Squirrel version>\tools`
- `%userprofile%\.nuget\packages\clowd.squirrel\2.7.89-pre\tools`, or;
- `..\packages\clowd.squirrel\2.7.89-pre\tools`
Once you have located the tools folder, create a release. Minimal example below with some useful options, but explore `Squirrel.exe -h` for a complete list.
```cmd

View File

@@ -1,3 +1,6 @@
using namespace System.IO
using namespace System.Text.RegularExpressions
Set-Location "$PSScriptRoot"
$ErrorActionPreference = "Stop"
@@ -5,9 +8,16 @@ $ErrorActionPreference = "Stop"
$gitVerJson = (&nbgv get-version -f json) | ConvertFrom-Json
$version = $gitVerJson.SimpleVersion + $gitVerJson.PrereleaseVersion
# build nuget package
& "$PSScriptRoot\vendor\NuGet.exe" pack "$PSScriptRoot\src\Clowd.Squirrel.nuspec" `
-BasePath "$PSScriptRoot\src" `
-OutputDirectory "$PSScriptRoot\build" `
-Version $version
# build zip for github releases
& "$PSScriptRoot\vendor\7zip\7z.exe" a "$PSScriptRoot\build\SquirrelTools-$version.zip" -tzip -aoa -y -mmt on "$PSScriptRoot\build\publish\*"
# update readme examples with latest version
$readmePath = "$PSScriptRoot\README.md"
$newText = [Regex]::Replace([File]::ReadAllText($readmePath), "Clowd\.Squirrel\\.+?\\tools", "clowd.squirrel\$version\tools", [RegexOptions]::Multiline + [RegexOptions]::IgnoreCase)
[File]::WriteAllText($readmePath, $newText)