-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildRelease.ps1
43 lines (36 loc) · 1.28 KB
/
buildRelease.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$package = "github.com/mpotthoff/git-lfs-webdav"
$projectname = "git-lfs-webdav"
$outputdir = "build"
# Check dirty repo
git diff --no-patch --exit-code
if ($LASTEXITCODE -ne 0) {
Write-Output "Working copy is not clean (unstaged changes)"
Exit $LASTEXITCODE
}
git diff --no-patch --cached --exit-code
if ($LASTEXITCODE -ne 0) {
Write-Output "Working copy is not clean (staged changes)"
Exit $LASTEXITCODE
}
# Check that the latest tag is present directly on HEAD
$version = (git describe --exact-match | Out-String).Trim()
if ($LASTEXITCODE -ne 0) {
Write-Output "No version tag on HEAD"
Exit $LASTEXITCODE
}
# Get the Git-Hash
$hash = (git rev-parse --short HEAD | Out-String).Trim()
if ($LASTEXITCODE -ne 0) {
Write-Output "Failed to get hash of HEAD"
Exit $LASTEXITCODE
}
Write-Output "Building version: $version"
$env:GOOS="windows"
$env:GOARCH="amd64"
go build -ldflags "-s -w -X $package/internal.Version=$version-$hash" -o "$outputdir/$projectname-windows-amd64.exe"
$env:GOOS="linux"
$env:GOARCH="amd64"
go build -ldflags "-s -w -X $package/internal.Version=$version-$hash" -o "$outputdir/$projectname-linux-amd64"
$env:GOOS="darwin"
$env:GOARCH="amd64"
go build -ldflags "-s -w -X $package/internal.Version=$version-$hash" -o "$outputdir/$projectname-darwin-amd64"