-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild
executable file
·45 lines (37 loc) · 1.57 KB
/
build
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
#!/usr/bin/bash
OS=( linux windows darwin )
ARCH=( amd64 arm arm64 )
test -d dist || mkdir dist
function d {
echo "[ $(date) ] $1"
}
function ldflags_pmm_dump {
BRANCH=$(git branch --show-current)
COMMIT=$(git rev-parse --short HEAD)
VERSION=$(git describe --tags --abbrev=0)
echo "-X 'main.GitBranch=${BRANCH}' -X 'main.GitCommit=${COMMIT}' -X 'main.GitVersion=${VERSION}'"
}
function ldflags_pt {
CP=')'
VERSION=$(git log --no-walk --tags --pretty="%H %d" --decorate=short | head -n1 | awk -F'[, $(CP)]' '{ print $7; }')
BUILD=$(date "+%FT%T%z")
GOVERSION=$(go version | cut --delimiter=" " -f3)
COMMIT=$(git rev-list -1 HEAD)
echo "-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.GoVersion=${GOVERSION} -X main.Commit=${COMMIT} -s -w"
}
for os_ in ${OS[@]}; do
for arch_ in ${ARCH[@]}; do
test $( go tool dist list | grep -wc $os_/$arch_ ) -ne 1 && continue
test "$os_/$arch_" == "windows/arm" && continue;
cd pmm-dump
d "Building pmm-dump on $os_/$arch_"
GOOS=${os_} GOARCH=${arch_} go build -ldflags "$(ldflags_pmm_dump)" -o ../dist/pmm-dump.${os_}.${arch_} pmm-dump/cmd/pmm-dump
cd ..
cd percona-toolkit/src/go
for pkg in pt-k8s-debug-collector pt-mongodb-index-check pt-mongodb-query-digest pt-mongodb-summary pt-pg-summary pt-secure-collect; do
d "Building $pkg on $os_/$arch_"
GOOS=${os_} GOARCH=${arch_} go build -ldflags "$(ldflags_pt)" -o ../../../dist/${pkg}.${os_}.${arch_} ./${pkg}
done;
cd ../../..
done;
done;