-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sh
executable file
·55 lines (43 loc) · 1.46 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
48
49
50
51
52
53
54
55
#!/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/xioc-linux64-${VERSION}"
GOOS=windows GOARCH=amd64 go build -ldflags '-s -w' -o "release/xioc-win64-${VERSION}.exe"
GOOS=darwin GOARCH=amd64 go build -ldflags '-s -w' -o "release/xioc-macos64-${VERSION}"
(
# zip
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 xioc-linux64-*
mv -f ./deb/bin/xioc-linux64-* ./deb/bin/xioc
mkdir -p ./deb/DEBIAN
cat > ./deb/DEBIAN/control <<EOF
Package: xioc
Version: $(echo "${VERSION}" | tr -d v)
Priority: optional
Architecture: amd64
Maintainer: Assaf Morami <assaf.morami@gmail.com>
Homepage: https://github.com/assafmo/xioc
Installed-Size: $(ls -l --block-size=KB ./deb/bin/xioc | awk '{print $5}' | tr -d 'kB')
Description: Extract indicators of compromise from text, including "escaped" ones.
EOF
dpkg-deb --build ./deb/ .
rm -rf ./deb/
)
# publish ubuntu snap
rm -rf snap *.snap* *_source.tar.bz2
snapcraft
snapcraft push *.snap
REV=$(snapcraft list-revisions xioc | head -2 | tail -1 | awk '{print $1}')
snapcraft release xioc "$REV" stable
snapcraft clean
rm -rf snap *.snap* *_source.tar.bz2