-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sh
executable file
·47 lines (37 loc) · 1.32 KB
/
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
#!/bin/bash
# build into ./release/
set -e
set -v
go test -race -cover ./...
rm -rf release
mkdir -p release
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
# https://golang.org/doc/install/source#environment
GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o "release/joincap-linux64-${VERSION}"
GOOS=windows GOARCH=amd64 go build -ldflags '-s -w' -o "release/joincap-win64-${VERSION}.exe"
GOOS=darwin GOARCH=amd64 go build -ldflags '-s -w' -o "release/joincap-macos64-${VERSION}"
GOOS=linux GOARCH=arm64 go build -ldflags '-s -w' -o "release/joincap-linux-arm64-${VERSION}"
(
# zip
set -e
cd release
find -type f |
parallel --bar 'zip "$(echo "{}" | sed "s/.exe//").zip" "{}" && rm -f "{}"'
# deb
mkdir -p ./deb/bin
unzip -o -d ./deb/bin joincap-linux64-*.zip
mv -f ./deb/bin/joincap-linux64-* ./deb/bin/joincap
mkdir -p ./deb/DEBIAN
cat > ./deb/DEBIAN/control <<EOF
Package: joincap
Version: $(echo "${VERSION}" | tr -d v)
Priority: optional
Architecture: amd64
Maintainer: Assaf Morami <[email protected]>
Homepage: https://github.com/assafmo/joincap
Installed-Size: $(ls -l --block-size=KB ./deb/bin/joincap | awk '{print $5}' | tr -d 'kB')
Description: Merge multiple pcap files together, gracefully.
EOF
dpkg-deb --build ./deb/ .
rm -rf ./deb
)