Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
automatically update readme example versions when packing nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Jan 24, 2022
1 parent 91b2cf5 commit 243c419
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion pack.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
using namespace System.IO
using namespace System.Text.RegularExpressions

Set-Location "$PSScriptRoot"
$ErrorActionPreference = "Stop"

# get current git version
$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\*"
# 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)

0 comments on commit 243c419

Please sign in to comment.