-
Notifications
You must be signed in to change notification settings - Fork 2
/
build
100 lines (90 loc) · 2.92 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
start=`date +%s`
builds=0
go get github.com/cavaliercoder/[email protected]
VERBASE=`date "+%Y%m%d%H%M"`
REPOHASH=`cat .git/HEAD | awk '{print $2}'`
COMMIT=`cat .git/$REPOHASH`
echo "Building commit ${COMMIT} as version ${VERBASE}"
mkdir -p out/${COMMIT: -5}
sed -i "s/{{COMMITHASH}}/${COMMIT}/" main.go
GOOS="windows"
GOARCH="amd64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/{{BUILDNAME}}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT.exe
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
GOOS="linux"
GOARCH="amd64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
OLDVER="${VER}"
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/${OLDVER}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
GOOS="freebsd"
GOARCH="amd64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
OLDVER="${VER}"
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/${OLDVER}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
GOOS="darwin"
GOARCH="amd64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
OLDVER="${VER}"
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/${OLDVER}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
GOOS="linux"
GOARCH="arm64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
OLDVER="${VER}"
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/${OLDVER}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
GOOS="freebsd"
GOARCH="arm64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
OLDVER="${VER}"
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/${OLDVER}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
GOOS="darwin"
GOARCH="arm64"
env GOOS=${GOOS} GOARCH=${GOARCH} > /dev/null 2>&1
OLDVER="${VER}"
VER="${VERBASE}-${GOOS}-${GOARCH}"
sed -i "s/${OLDVER}/${VER}/" main.go
OUTPUT="out/${COMMIT: -5}/$GOARCH/$GOOS"
go build -o $OUTPUT
((builds=builds+1))
echo "Built ${VERBASE} for ${GOOS} on ${GOARCH}! - ${OUTPUT}"
sed -i "s/${VER}/{{BUILDNAME}}/" main.go
sed -i "s/${COMMIT}/{{COMMITHASH}}/" main.go
end=`date +%s`
taken=$((end-start))
echo "Built for ${builds} platforms in ${taken} seconds."
if [[ "$#" -gt 0 ]]; then
if [ $1 == "--sign" ]; then
signtool sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /n "CreeperHost LTD" "out/${COMMIT: -5}/amd64/windows.exe"
signtool sign /as /tr http://timestamp.digicert.com /td sha1 /fd sha1 /n "CreeperHost LTD" "out/${COMMIT: -5}/amd64/windows.exe"
fi
fi