forked from trustpilot/beat-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·34 lines (29 loc) · 1.37 KB
/
build.sh
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
#!/bin/bash
set -e
if [[ -z "$GITHUB_WORKSPACE" ]]; then
GITHUB_WORKSPACE=$(pwd)
echo "Setting up GITHUB_WORKSPACE to current directory: ${GITHUB_WORKSPACE}"
fi
if [[ -z "$GITHUB_ACTOR" ]]; then
GITHUB_ACTOR=$(whoami)
echo "Setting up GITHUB_ACTOR to current user: ${GITHUB_ACTOR}"
fi
GITVERSION=$(git describe --tags --always)
GITBRANCH=$(git branch | grep \* | cut -d ' ' -f2)
GITREVISION=$(git log -1 --oneline | cut -d ' ' -f1)
TIME=$(date +%FT%T%z)
LDFLAGS="-s -X github.com/prometheus/common/version.Version=${GITVERSION} \
-X github.com/prometheus/common/version.Revision=${GITREVISION} \
-X github.com/prometheus/common/version.Branch=master \
-X github.com/prometheus/common/version.BuildUser=${GITHUB_ACTOR} \
-X github.com/prometheus/common/version.BuildDate=${TIME}"
for OS in "darwin" "linux" "windows"; do
for ARCH in "amd64" "386"; do
echo "Building ${OS}/${ARCH} with version: ${GITVERSION}, revision: ${GITREVISION}, buildUser: ${GITHUB_ACTOR}"
if [[ $OS == "windows" ]]; then
GO111MODULE=on CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags "${LDFLAGS}" -tags 'netgo static_build' -a -o ".build/${OS}-${ARCH}/beat-exporter.exe"
else
GO111MODULE=on CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags "${LDFLAGS}" -tags 'netgo static_build' -a -o ".build/${OS}-${ARCH}/beat-exporter"
fi
done
done