#!/bin/bash set -e cur_date="`date +%Y-%m-%d`" ROOT=$(cd `dirname $0`; pwd) mkdir -p $ROOT/tmp rm -rf $ROOT/tmp/* # ----- Start build ----- mkdir -p $ROOT/cache cd $ROOT/cache BUILDTIME_STR=`date '+%Y-%m-%d %H:%M:%S'` CGO_ENABLED=0 go build -ldflags "-X \"main.buildtime=$BUILDTIME_STR\"" -o ./watch-daemon-x64 $ROOT/ CGO_ENABLED=0 GOARCH=arm64 go build -ldflags "-X \"main.buildtime=$BUILDTIME_STR\"" -o ./watch-daemon-arm64 $ROOT/ # ----- End build ----- cd $ROOT/tmp cp -rf $ROOT/watch-daemon $ROOT/tmp/ cp -rf $ROOT/watch-daemon-installer $ROOT/tmp/ cp -rf $ROOT/config $ROOT/tmp/watch-daemon/ mkdir -p $ROOT/tmp/watch-daemon/log cp -rf $ROOT/cache/watch-daemon-x64 $ROOT/tmp/watch-daemon/watch-daemon tar -zcf $ROOT/tmp/watch-daemon-installer/watch-daemon-x64.tar.gz watch-daemon rm -f $ROOT/tmp/watch-daemon/watch-daemon cp -rf $ROOT/cache/watch-daemon-arm64 $ROOT/tmp/watch-daemon/watch-daemon tar -zcf $ROOT/tmp/watch-daemon-installer/watch-daemon-arm64.tar.gz watch-daemon rm -f $ROOT/tmp/watch-daemon/watch-daemon cd $ROOT if [ ! -d "release" ]; then mkdir -p release fi cd $ROOT/tmp tar -zcf $ROOT/release/watch-daemon-universal-installer-v${cur_date}.tar.gz watch-daemon-installer rm -rf $ROOT/tmp/* rmdir $ROOT/tmp echo "打包成功"