-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathPSBuild.ps1
76 lines (65 loc) · 1.93 KB
/
PSBuild.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Param (
[string]$version = "dev"
)
$ErrorActionPreference = "Stop"
Write-Output "Running PSBuild.ps1..."
Write-Output ""
$deploy=".\deploy"
$target="$($deploy)\windows\sqlxewriter"
Write-Output "Deploy: $deploy"
Write-Output "Target: $target"
If ($Version -eq "") {
Write-Output "Missing Version"
Exit
}
Write-Output "Version: $($version)"
# Clean deploy directory
If (Test-Path $target) {
Remove-Item $target -Recurse
}
# $now = Get-Date -UFormat "%Y-%m-%d_%T_%Z"
$now = Get-Date -Format "yyyy'-'MM'-'dd'T'HH':'mm':'sszzz"
$sha1 = (git describe --tags --dirty --always).Trim()
Write-Output "Git: $sha1"
Write-Output "Build: $now"
Write-Output ""
Write-Output "Running go vet..."
go vet -all .\cmd\sqlxewriter
if ($LastExitCode -ne 0) {
exit
}
go vet -all .\pkg\...
if ($LastExitCode -ne 0) {
exit
}
Write-Output "Running go test..."
go test .\cmd\xelogstash ./cmd/sqlxewriter .\pkg\...
if ($LastExitCode -ne 0) {
exit
}
Write-Output "Building sqlxewriter.exe..."
go build -o "$($target)\sqlxewriter.exe" -a -ldflags "-X main.sha1ver=$sha1 -X main.buildTime=$now -X main.version=$version" ".\cmd\sqlxewriter"
if ($LastExitCode -ne 0) {
exit
}
.\Deploy\Windows\SQLXEWriter\SQLXEWriter.exe -version
Write-Output "Copying Files..."
blackfriday-tool -css .\docs\style.css -embed README.md "README.html"
blackfriday-tool -css .\docs\style.css -embed LICENSE.md "LICENSE.html"
Copy-Item -Path README.html -Destination $target
Copy-Item -Path LICENSE.html -Destination $target
Copy-Item -Path ".\samples\sqlxewriter.toml" -Destination $target
Copy-Item -Path ".\samples" -Destination $target -Recurse
$stdZip = "$($deploy)\sqlxewriter_$($version)_windows_x64.zip"
If (Test-Path $stdZip) {
Remove-Item $stdZip
}
Write-Host "Writing $($stdZip)..."
$stdCompress = @{
Path = $target
CompressionLevel = "Fastest"
DestinationPath = $stdZip
Update = $true
}
Compress-Archive @stdCompress
Write-Output "Done."