forked from goss-org/goss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-build.sh
executable file
·39 lines (31 loc) · 968 Bytes
/
release-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
35
36
37
38
39
#!/usr/bin/env bash
set -euo pipefail
platform_spec="${1:?"Must supply name of release binary to build e.g. goss-linux-amd64"}"
version_stamp="${TRAVIS_TAG:-"0.0.0"}"
# Split platform_spec into platform/arch segments
IFS='- ' read -r -a segments <<< "${platform_spec}"
os="${segments[0]}"
arch="${segments[1]}"
if [[ "${segments[0]}" == "alpha" ]]; then
os="${segments[1]}"
arch="${segments[2]}"
fi
output_dir="release/"
output_fname="goss-${platform_spec}"
if [[ "${os}" == "windows" ]]; then
output_fname="${output_fname}.exe"
fi
output="${output_dir}/${output_fname}"
GOOS="${os}" GOARCH="${arch}" CGO_ENABLED=0 go build \
-ldflags "-X main.version=${version_stamp} -s -w" \
-o "${output}" \
github.com/goss-org/goss/cmd/goss
chmod +x "${output}"
function __sha256sum {
if [[ "$OSTYPE" == "darwin"* ]]; then
shasum -a 256 "$1"
else
sha256sum "$1"
fi
}
(cd "$output_dir" && __sha256sum "${output_fname}" > "${output_fname}.sha256")