forked from ananthb/mikrotik-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·49 lines (41 loc) · 940 Bytes
/
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
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#
# $1 - The version number to use for the build. If not provided, the current git
# commit hash will be used.
#
set -euo pipefail
app="$(basename "$PWD")"
version="${1:-$(git rev-parse --short HEAD)}"
rm -rf bin
mkdir -p bin
pushd bin
trap popd EXIT
gobuild() {
mkdir -p "$1/$2"
pushd "$1/$2"
env GOOS="$1" GOARCH="$2" go build ../../../.
case "$1" in
"windows")
zip ../../"${app}_${1}_${2}_${version}".zip ./*.exe
;;
"linux")
tar -c --zstd --numeric-owner \
-f ../../"${app}_${1}_${2}_${version}".tar.zst .
;;
*)
tar -c --numeric-owner \
-f ../../"${app}_${1}_${2}_${version}".tar.bz2 .
;;
esac
rm ./*
popd
rmdir "${1:?}/${2:?}" "${1:?}"
}
export CGO_ENABLED=0
# Binaries for all platforms
gobuild linux amd64
gobuild linux arm64
gobuild darwin amd64
gobuild darwin arm64
gobuild windows amd64
sha1sum ./*.tar.* ./*.zip >sha1sums.txt