package-all.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -e
  3. cur_date="`date +%Y-%m-%d`"
  4. ROOT=$(cd `dirname $0`; pwd)
  5. mkdir -p $ROOT/tmp
  6. rm -rf $ROOT/tmp/*
  7. # ----- Start build -----
  8. mkdir -p $ROOT/cache
  9. cd $ROOT/cache
  10. BUILDTIME_STR=`date '+%Y-%m-%d %H:%M:%S'`
  11. CGO_ENABLED=0 go build -ldflags "-X \"main.buildtime=$BUILDTIME_STR\"" -o ./watch-daemon-x64 $ROOT/
  12. CGO_ENABLED=0 GOARCH=arm64 go build -ldflags "-X \"main.buildtime=$BUILDTIME_STR\"" -o ./watch-daemon-arm64 $ROOT/
  13. # ----- End build -----
  14. cd $ROOT/tmp
  15. cp -rf $ROOT/watch-daemon $ROOT/tmp/
  16. cp -rf $ROOT/watch-daemon-installer $ROOT/tmp/
  17. cp -rf $ROOT/config $ROOT/tmp/watch-daemon/
  18. mkdir -p $ROOT/tmp/watch-daemon/log
  19. cp -rf $ROOT/cache/watch-daemon-x64 $ROOT/tmp/watch-daemon/watch-daemon
  20. tar -zcf $ROOT/tmp/watch-daemon-installer/watch-daemon-x64.tar.gz watch-daemon
  21. rm -f $ROOT/tmp/watch-daemon/watch-daemon
  22. cp -rf $ROOT/cache/watch-daemon-arm64 $ROOT/tmp/watch-daemon/watch-daemon
  23. tar -zcf $ROOT/tmp/watch-daemon-installer/watch-daemon-arm64.tar.gz watch-daemon
  24. rm -f $ROOT/tmp/watch-daemon/watch-daemon
  25. cd $ROOT
  26. if [ ! -d "release" ]; then
  27. mkdir -p release
  28. fi
  29. cd $ROOT/tmp
  30. tar -zcf $ROOT/release/watch-daemon-universal-installer-v${cur_date}.tar.gz watch-daemon-installer
  31. rm -rf $ROOT/tmp/*
  32. rmdir $ROOT/tmp
  33. echo "打包成功"