1#!/bin/bash
2
3BUILD_FOLDER=build
4VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2)
5
6bin_dep() {
7  BIN=$1
8  which $BIN > /dev/null || { echo "[-] Dependency $BIN not found !"; exit 1; }
9}
10
11create_exe_archive() {
12  bin_dep 'zip'
13
14  OUTPUT=$1
15
16  echo "[*] Creating archive $OUTPUT ..."
17  zip -j "$OUTPUT" aquatone.exe ../README.md ../LICENSE.txt > /dev/null
18  rm -rf aquatone aquatone.exe
19}
20
21create_archive() {
22  bin_dep 'zip'
23
24  OUTPUT=$1
25
26  echo "[*] Creating archive $OUTPUT ..."
27  zip -j "$OUTPUT" aquatone ../README.md ../LICENSE.txt > /dev/null
28  rm -rf aquatone aquatone.exe
29}
30
31build_linux_amd64() {
32  echo "[*] Building linux/amd64 ..."
33  GOOS=linux GOARCH=amd64 go build -o aquatone ..
34}
35
36build_linux_arm64() {
37  echo "[*] Building linux/arm64 ..."
38  GOOS=linux GOARCH=arm go build -o aquatone ..
39}
40
41build_macos_amd64() {
42  echo "[*] Building darwin/amd64 ..."
43  GOOS=darwin GOARCH=amd64 go build -o aquatone ..
44}
45
46build_windows_amd64() {
47  echo "[*] Building windows/amd64 ..."
48  GOOS=windows GOARCH=amd64 go build -o aquatone.exe ..
49}
50
51rm -rf $BUILD_FOLDER
52mkdir $BUILD_FOLDER
53cd $BUILD_FOLDER
54
55build_linux_amd64 && create_archive aquatone_linux_amd64_$VERSION.zip
56build_linux_arm64 && create_archive aquatone_linux_arm64_$VERSION.zip
57build_macos_amd64 && create_archive aquatone_macos_amd64_$VERSION.zip
58build_windows_amd64 && create_exe_archive aquatone_windows_amd64_$VERSION.zip
59shasum -a 256 * > checksums.txt
60
61echo
62echo
63du -sh *
64
65cd --
66