-
Notifications
You must be signed in to change notification settings - Fork 15
/
release.sh
executable file
·87 lines (74 loc) · 2.27 KB
/
release.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
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
#!/bin/sh
#
# Create release tarballs/zip-files
#
platforms="
linux,amd64,,linux_x86_64_static,tar.xz
linux,arm64,,linux_aarch64_static,tar.xz
linux,arm,6,linux_armv6_static,tar.xz
linux,arm,7,linux_armv7_static,tar.xz
linux,riscv64,,linux_riscv64_static,tar.xz
darwin,amd64,,macos_x86_64_static,tar.gz
darwin,arm64,,macos_aarch64_static,tar.gz
freebsd,amd64,,freebsd_x86_64_static,tar.gz
freebsd,arm64,,freebsd_aarch64_static,tar.gz
freebsd,arm,6,freebsd_armv6_static,tar.gz
freebsd,arm,7,freebsd_armv7_static,tar.gz
freebsd,386,,freebsd_i386_static,tar.gz
netbsd,amd64,,netbsd_x86_64_static,tar.gz
netbsd,arm64,,netbsd_aarch64_static,tar.gz
netbsd,arm,6,netbsd_armv6_static,tar.gz
netbsd,arm,7,netbsd_armv7_static,tar.gz
netbsd,386,,netbsd_i386_static,tar.gz
"
# plan9,amd64,,plan9_x86_64_static,tar.gz
cd v2
name=orbiton
version=$(grep -i version main.go | head -1 | cut -d' ' -f4 | cut -d'"' -f1)
echo "Version $version"
export CGO_ENABLED=0
compile_and_compress() {
goos="$1"
goarch="$2"
goarm="$3"
platform="$4"
compression="$5"
echo "Compiling $name.$platform..."
[ -n "$goarm" ] && GOARM="$goarm" || unset GOARM
GOOS="$goos" GOARCH="$goarch" go build -mod=vendor -trimpath -ldflags="-s -w" -a -o "$name.$platform" || {
echo "Error: failed to compile for $platform"
echo "Platform string: $p"
echo "Environment variables: GOOS=$goos GOARCH=$goarch GOARM=$goarm"
exit 1
}
echo "Compressing $name-$version.$platform.$compression"
mkdir "$name-$version-$platform"
cp ../o.1 "$name-$version-$platform/"
gzip "$name-$version-$platform/o.1"
cp "$name.$platform" "$name-$version-$platform/o"
cp ../LICENSE "$name-$version-$platform/"
case "$compression" in
tar.xz)
tar Jcf "$name-$version-$platform.$compression" "$name-$version-$platform"
;;
tar.gz)
tar zcf "$name-$version-$platform.$compression" "$name-$version-$platform"
;;
esac
rm -r "$name-$version-$platform"
rm "$name.$platform"
}
echo 'Compiling...'
while read -r p; do
[ -z "$p" ] && continue
IFS=',' read -r goos goarch goarm platform compression <<EOF
$p
EOF
compile_and_compress "$goos" "$goarch" "$goarm" "$platform" "$compression" &
done <<EOF
$platforms
EOF
wait
cd ..
mkdir -p release
mv -v v2/$name-$version* release