summaryrefslogtreecommitdiffstats
path: root/make.sh
blob: 132657ad76710f77d07c108d5ef4e425ed1466db (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

export VERSION=$(go run ./cmd/gotop -V)

rm -f build.log

function candz() {
	export GOOS=$1
	export GOARCH=$2
	OUT=build/gotop_${VERSION}_${GOOS}_${GOARCH}
	if [[ -n $3 ]]; then
		export GOARM=$3
		OUT=${OUT}_v${GOARM}
	fi
	OUT=${OUT}.zip
	if [[ -e $OUT ]]; then
		echo SKIP $OUT
		return
	fi
	D=build/gotop
	if [[ $GOOS == "windows" ]]; then
		D=${D}.exe
	fi
	go build -o $D ./cmd/gotop >> build.log 2>&1 
	if [[ $? -ne 0 ]]; then
		printenv | grep GO >> build.log
		echo "############### FAILED ###############" >> build.log
		echo >> build.log
		echo >> build.log
		echo FAILED $OUT
		return
	fi
	unset GOOS GOARCH GOARM CGO_ENABLED
	cd build
	zip $(basename $OUT) $(basename $D) >> ../build.log 2>&1
	cd ..
	rm -f $D
	if [[ $? -ne 0 ]]; then
		echo "############### FAILED ###############" >> build.log
		echo >> build.log
		echo >> build.log
		echo FAILED $OUT
		return
	fi
	echo BUILT $OUT
}

candz linux arm64
for x in 5 6 7; do
	candz linux arm $x
done
for x in 386 amd64; do
	candz linux $x

	sed -i "s/arch: .*/arch: \"${x}\"/" build/nfpm.yml
	for y in rpm deb; do
		OUT=build/gotop_${VERSION}_linux_${x}.${y}
		if [[ -e $OUT ]]; then
			echo SKIP $OUT
		else
			echo Building $OUT
			nfpm pkg -t ${OUT} -f build/nfpm.yml
		fi
	done

	candz windows $x
	candz freebsd $x

	export CGO_ENABLED=1
	candz darwin $x
	candz openbsd $x
	unset CGO_ENABLED
done

rm -f build/gotop