-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-mac.ps1
33 lines (28 loc) · 1.22 KB
/
build-mac.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
Set-Location ./src/host
$imageName = "redismanager"
$targetDir = "../../dist/mac/"
$binPathAMD64 = $targetDir + $imageName + "_amd64"
$binPathARM64 = $targetDir + $imageName + "_arm64"
$APP_NAME = "Redis Manager"
$APP_VERSION = $(git describe --tags --abbrev=0)
$BUILD_VERSION = $(git log -1 --oneline)
$BUILD_TIME=$(Get-Date -Format "UTCK = yyyy-MM-dd HH:mm:ss")
# $GIT_REVISION=$(git rev-parse --short HEAD)
$GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# $GIT_TAG=$(git name-rev --name-only HEAD)
$GO_VERSION=$(go version)
$FLAGS = "-s -w -X 'main.AppName=${APP_NAME}'`
-X 'main.AppVersion=${APP_VERSION}'`
-X 'main.BuildVersion=${BUILD_VERSION}'`
-X 'main.BuildTime=${BUILD_TIME}'`
-X 'main.GitBranch=${GIT_BRANCH}'`
-X 'main.GoVersion=${GO_VERSION}'"
Write-Host "#: building executable file..."
$env:GOOS = "darwin"; $env:GOARCH = "amd64"; go build -ldflags $FLAGS -o $binPathAMD64 ./
$env:GOOS = "darwin"; $env:GOARCH = "arm64"; go build -ldflags $FLAGS -o $binPathARM64 ./
# Write-Host "#: compressing executable file..."
# upx $binPath
Write-Host "#: copying configs file..."
Copy-Item ./configstemplate.json $targetDir"configs.json"
Write-Host "#: done"
Set-Location ../../