created new build script for powershell

This commit is contained in:
Greg Gauthier 2024-07-09 23:33:44 +01:00
parent fd70f428ae
commit ea29c29531

18
build.ps1 Normal file
View File

@ -0,0 +1,18 @@
$current_directory = "$(pwd.exe)"
Set-Variable -Name GOPATH -Value "$HOME/go:$current_directory"
# NOTE: The following commands assumes you have Git For Windows
# installed, which comes with a bunch of GNU tools packaged for windows:
Set-Variable -Name GIT_COMMIT -Value "$(git rev-list -1 HEAD)"
Set-Variable -Name CANONICAL_VERSION -Value "$(cat.exe ./VERSION)-$(uname)"
Set-Variable -Name VERSION_STRING -Value "$CANONICAL_VERSION-$GIT_COMMIT"
Set-Variable -Name buildpath -Value "build/$(uname)/gostations.exe"
go mod vendor
go mod tidy
go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING"
& $buildpath -v