diff --git a/Build.ps1 b/Build.ps1 index b7cdb29..882e35a 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -61,7 +61,7 @@ Write-Output "build: Project .csproj file is located at $project" Write-Output "build: Getting Version from $project" $xml = [Xml](Get-Content $project) -$prefix = [Version]$xml.Project.PropertyGroup.VersionPrefix.ToString() +$prefix = [Version]$xml.Project.PropertyGroup[0].VersionPrefix.ToString() Write-Output "build: Version prefix is $prefix" Write-Output "build: Calculating `$branch, `$revision, and `$suffix" @@ -78,7 +78,7 @@ Write-Output "build: Version is $version" Write-Output "build: Creating artifacts directory at .\$artifacts" New-Item -ItemType "directory" -Name $artifacts -Write-Output "build: Packing library into .nupkg" +Write-Output "build: Packing library into Datalust.Piggy.*.nupkg" if ($suffix) { & dotnet pack $project -c Release -o $PSScriptRoot/$artifacts /p:OutputType=Library --version-suffix=$suffix } else { @@ -86,6 +86,14 @@ if ($suffix) { } if($LASTEXITCODE -ne 0) { exit 11 } +Write-Output "build: Packing executable into dotnet tool Datalust.Piggy.Cli.*.nupkg" +if ($suffix) { + & dotnet pack $project -c Release -o $PSScriptRoot/$artifacts /p:PackAsTool=True --version-suffix=$suffix +} else { + & dotnet pack $project -c Release -o $PSScriptRoot/$artifacts /p:PackAsTool=True +} +if($LASTEXITCODE -ne 0) { exit 11 } + $rids = @("win-x64", "linux-x64", "osx-x64", "osx-arm64") foreach ($rid in $rids) { Write-Output "build: Building a $rid build of version $version" diff --git a/README.md b/README.md index 67ff0cd..42bf149 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,38 @@ Piggy is a simple command-line tool for managing schema and data changes to Post ### Installation -Piggy is available for Windows, macOS and Linux from [the releases page](https://github.com/datalust/piggy/releases). If your platform of choice isn't listed, please [raise an issue here](https://github.com/datalust/piggy/issues) so that we can add it. +Piggy is available as a .NET tool package, as standalone binaries, and as a C♯ library that can be used directly in .NET applications. + +#### `dotnet tool` + +Piggy is distributed as a [.NET tool package called _Datalust.Piggy.Cli_](https://nuget.org/packages/datalust.piggy.cli), which can be installed using: + +``` +dotnet tool install --global Datalust.Piggy.Cli +``` + +The executable is called `piggy`. Test that the installation was successful with: + +``` +piggy version +``` + +#### Executable binaries + +Pre-built, native, self-contained Piggy binaries are available for Windows, macOS and Linux from [the releases page](https://github.com/datalust/piggy/releases). If your platform of choice isn't listed, please [raise an issue here](https://github.com/datalust/piggy/issues) so that we can add it. + +#### C# library + +For development and test automation purposes, the core script runner is also packaged as a C♯ API and [published to NuGet as _Datalust.Piggy_](https://nuget.org/packages/datalust.piggy). + +```csharp +// dotnet add package Datalust.Piggy +var connectionString = // Npgsql connection string +using (var connection = DatabaseConnector.Connect(connectionString)) +{ + UpdateSession.ApplyChangeScripts(connection, "./db", new Dictionary()); +} +``` ### Workflow @@ -100,16 +131,3 @@ Available commands are: Type `piggy help ` for detailed help ``` - -### C♯ API - -For development and test automation purposes, the core script runner is also packaged as a C♯ API and published to NuGet as _Datalust.Piggy_. - -```csharp -// dotnet add package Datalust.Piggy -var connectionString = // Npgsql connection string -using (var connection = DatabaseConnector.Connect(connectionString)) -{ - UpdateSession.ApplyChangeScripts(connection, "./db", new Dictionary()); -} -``` diff --git a/src/Datalust.Piggy/Datalust.Piggy.csproj b/src/Datalust.Piggy/Datalust.Piggy.csproj index ac28ef0..e5d9edc 100644 --- a/src/Datalust.Piggy/Datalust.Piggy.csproj +++ b/src/Datalust.Piggy/Datalust.Piggy.csproj @@ -22,6 +22,12 @@ true README.md + + + Datalust.Piggy.Cli + piggy + Major +