#!/bin/bash # 任意一步失败立即退出,避免没编出二进制也照样上传重启 set -e cd "$(dirname "$0")" # 终端 PATH 里没有 go 时兜底用 ~/sdk/go if ! command -v go >/dev/null 2>&1 && [ -x "$HOME/sdk/go/bin/go" ]; then export PATH="$HOME/sdk/go/bin:$PATH" fi echo "开始" rm -rf ./web_huangguo_h5 ./web_huangguo_h5.tar.gz GOOS=linux GOARCH=amd64 go build -o web_huangguo_h5 # --exclude 必须放在文件列表前面,macOS 的 bsdtar 会把后面的参数当文件名; # COPYFILE_DISABLE / --no-xattrs 不打包 macOS 扩展属性,免得服务器 tar 报 LIBARCHIVE.xattr COPYFILE_DISABLE=1 tar zvcf web_huangguo_h5.tar.gz --no-xattrs \ --exclude='templates/page/sitemaps/sitemap.xml' \ --exclude='templates/page/sitemaps/sitemap-*.xml' \ --exclude='templates/page/rss.xml' \ --exclude='templates/page/llms.txt' \ --exclude='templates/page/llms-full.txt' \ web_huangguo_h5 templates/ static/ scp web_huangguo_h5.tar.gz root@172.104.166.87:/data/uzip ssh root@172.104.166.87 "/server/web_huangguo/h5/up_app.sh" rm -rf ./web_huangguo_h5 ./web_huangguo_h5.tar.gz