From 243c4191c6e3bf75e21fd6519687e18e73b83325 Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Mon, 24 Jan 2022 23:39:54 +0000 Subject: [PATCH] automatically update readme example versions when packing nuget --- README.md | 4 ++-- pack.ps1 | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 010478bd..d827b8b8 100644 --- a/README.md +++ b/README.md @@ -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\\tools`, or; - - `..\packages\Clowd.Squirrel\\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 diff --git a/pack.ps1 b/pack.ps1 index 086502fa..f84819a1 100644 --- a/pack.ps1 +++ b/pack.ps1 @@ -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 -& "$PSScriptRoot\vendor\7zip\7z.exe" a "$PSScriptRoot\build\SquirrelTools-$version.zip" -tzip -aoa -y -mmt on "$PSScriptRoot\build\publish\*" \ No newline at end of file +# 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) \ No newline at end of file