build(release): 客户端与服务端分开打包,macOS 提供 dmg 安装镜像

- 服务端:portrelay-server-<版本>-linux-{amd64,arm64}.tar.gz(含 deploy/ 安装脚本)
- 客户端:PortRelay-<版本>.dmg(通用版本),以及 Linux / Windows 的 portrelay-agent 压缩包
- make dmg 打包安装镜像;Release 说明按客户端 / 服务端列出下载项
This commit is contained in:
DeepFal committed 2026-10-14 10:41:38 +08:00
1 parent dceb59c0ca
commit c71668e82d
5 files changed
+88 -29

No files matched your search

+25 -11
View File
@@ -4,16 +4,19 @@
# make agent 编译当前平台的 Agent 到 bin/
# make app 构建 macOS 应用 PortRelay.app(需要 Xcode 命令行工具)
# make install-app 构建并替换 /Applications/PortRelay.app(正在运行的会先退出,装好后重新打开)
# make release 打包所有平台的服务端 / Agent 到 dist/
# make dmg 打包 macOS 安装镜像 dist/PortRelay-<版本>.dmg(UNIVERSAL=1 构建通用版本)
# make release 打包服务端(Linux)与命令行 Agent(Linux / Windows)到 dist/
# make snapshots 离屏渲染 App 界面截图(tools/ui-snapshots/out)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
GOBUILD := CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)"
PLATFORMS := linux/amd64 linux/arm64 darwin/arm64 darwin/amd64 windows/amd64
# 服务端只发布 Linux 版本;macOS 用户用 App,其余平台用命令行 Agent
SERVER_PLATFORMS := linux/amd64 linux/arm64
AGENT_PLATFORMS := linux/amd64 linux/arm64 windows/amd64
.PHONY: all test fmt server agent app install-app release snapshots clean
.PHONY: all test fmt server agent app install-app dmg release snapshots clean
all: test agent
@@ -47,20 +50,31 @@ install-app: app
echo "✓ 已安装 /Applications/PortRelay.app ($(VERSION))"; \
if [ -n "$$running" ]; then open /Applications/PortRelay.app; fi
# 安装镜像:PortRelay.app 和「应用程序」的快捷方式,打开后拖进去即可
dmg: app
@rm -rf build/dmg && mkdir -p build/dmg dist
ditto PortRelay.app build/dmg/PortRelay.app && rm -rf PortRelay.app
ln -s /Applications build/dmg/Applications
hdiutil create -volname PortRelay -srcfolder build/dmg -fs HFS+ -format UDZO -ov dist/PortRelay-$(VERSION).dmg
@rm -rf build/dmg
# 服务端:portrelay-server-<版本>-linux-<架构>.tar.gz(含 deploy/ 安装脚本)
# 客户端:portrelay-agent-<版本>-<系统>-<架构>.tar.gz / .zip
release:
@rm -rf dist && mkdir -p dist
@for p in $(PLATFORMS); do \
os=$${p%/*}; arch=$${p#*/}; ext=; [ $$os = windows ] && ext=.exe; \
name=portrelay-$(VERSION)-$$os-$$arch; mkdir -p dist/$$name; \
@rm -rf dist/portrelay-* dist/SHA256SUMS && mkdir -p dist
@pack() { \
cmd=$$1; os=$$2; arch=$$3; ext=; [ $$os = windows ] && ext=.exe; \
name=$$cmd-$(VERSION)-$$os-$$arch; mkdir -p dist/$$name; \
echo "==> $$name"; \
GOOS=$$os GOARCH=$$arch $(GOBUILD) -o dist/$$name/portrelay-server$$ext ./cmd/portrelay-server || exit 1; \
GOOS=$$os GOARCH=$$arch $(GOBUILD) -o dist/$$name/portrelay-agent$$ext ./cmd/portrelay-agent || exit 1; \
GOOS=$$os GOARCH=$$arch $(GOBUILD) -o dist/$$name/$$cmd$$ext ./cmd/$$cmd || return 1; \
cp LICENSE README.md README_EN.md dist/$$name/; \
if [ $$os = linux ]; then cp -R deploy dist/$$name/; fi; \
if [ $$cmd = portrelay-server ]; then cp -R deploy dist/$$name/; fi; \
if [ $$os = windows ]; then (cd dist && zip -qr $$name.zip $$name); \
else tar -C dist -czf dist/$$name.tar.gz $$name; fi; \
rm -rf dist/$$name; \
done
}; \
for p in $(SERVER_PLATFORMS); do pack portrelay-server $${p%/*} $${p#*/} || exit 1; done; \
for p in $(AGENT_PLATFORMS); do pack portrelay-agent $${p%/*} $${p#*/} || exit 1; done
@cd dist && shasum -a 256 * > SHA256SUMS && cat SHA256SUMS
snapshots: