build.sh 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/env bash
  2. set -x
  3. function RETVAL() {
  4. rt=$1
  5. if [ $rt != 0 ]; then
  6. echo $rt
  7. exit 1
  8. fi
  9. }
  10. #当前目录
  11. cpath=$(pwd)
  12. echo "编译前端项目"
  13. cd $cpath/web
  14. #国内可替换源加快速度
  15. #npx browserslist@latest --update-db
  16. #npm install --registry=https://registry.npm.taobao.org
  17. #npm install
  18. #npm run build
  19. yarn install
  20. yarn run build
  21. RETVAL $?
  22. echo "编译二进制文件"
  23. cd $cpath/server
  24. rm -rf ui
  25. cp -rf $cpath/web/ui .
  26. #国内可替换源加快速度
  27. export GOPROXY=https://goproxy.io
  28. go mod tidy
  29. go build -v -o anylink -ldflags "-X main.CommitId=$(git rev-parse HEAD)"
  30. RETVAL $?
  31. cd $cpath
  32. echo "整理部署文件"
  33. deploy="anylink-deploy"
  34. rm -rf $deploy ${deploy}.tar.gz
  35. mkdir $deploy
  36. cp -r server/anylink $deploy
  37. cp -r server/bridge-init.sh $deploy
  38. cp -r server/conf $deploy
  39. cp -r systemd $deploy
  40. cp -r LICENSE $deploy
  41. tar zcvf ${deploy}.tar.gz $deploy
  42. #注意使用root权限运行
  43. #cd anylink-deploy
  44. #sudo ./anylink --conf="conf/server.toml"