安装命令要成立,节点就得有个地方取二进制——节点上没有 Go 工具链,此前唯一的办法是在 另一台机器上编译再 scp,而这一步是安装命令表达不了的。 scripts/release.sh:编译两个 ARM 目标、生成 SHA256SUMS、建 release、上传三个附件。 令牌从 git 的 credential helper 读,所以进程表和 shell 历史里都没有它;也可以用 MSA_GITEA_TOKEN 覆盖。重跑会复用已存在的 release 并替换同名附件——修完东西重发时, 否则会静默留着上一个二进制。--dry-run 只编译和算校验值。 Makefile 的 VERSION 从 0.1.0 提到 0.3.0,并且它现在是二进制里真实带着的版本 (`msa-agent version` 与启动日志都会报),也是 release 的 tag。 已发布 v0.3.0:下载回来验过,sha256 与 SHA256SUMS 一致,是 ARM aarch64 静态 ELF, 且带着新的 enroll/uninstall 子命令。 Go 全包、Node 134 项、Swift 107 项通过。
46 lines
1.6 KiB
Makefile
46 lines
1.6 KiB
Makefile
POLICY_SRC := ../contracts/agent-policy.json
|
|
POLICY_DST := internal/policy/agent-policy.json
|
|
# The version stamped into the binary, and the tag scripts/release.sh publishes under. It is the
|
|
# agent's own version rather than the app's: the two are released together but a node can be running an
|
|
# older agent than the phone, and the handshake's `agentBuild` field is what makes that visible.
|
|
VERSION ?= 0.3.0
|
|
LDFLAGS := -s -w -X main.version=$(VERSION)
|
|
|
|
.PHONY: all vendor test vet build build-arm64 build-armv7 clean
|
|
|
|
all: vet test build
|
|
|
|
# The policy is embedded, so the vendored copy is part of the binary. Keep the copy mechanical:
|
|
# an operator editing internal/policy/agent-policy.json by hand would be editing a file the build
|
|
# overwrites, and the drift test makes that mistake loud rather than quiet.
|
|
vendor: $(POLICY_DST)
|
|
|
|
$(POLICY_DST): $(POLICY_SRC)
|
|
@cp $(POLICY_SRC) $(POLICY_DST)
|
|
|
|
test: vendor
|
|
@go test ./...
|
|
|
|
vet: vendor
|
|
@go vet ./...
|
|
|
|
fmt:
|
|
@gofmt -l -w .
|
|
|
|
build: vendor
|
|
@mkdir -p dist
|
|
@go build -trimpath -ldflags '$(LDFLAGS)' -o dist/msa-agent ./cmd/msa-agent
|
|
|
|
# Nodes are ARM Debian boxes that also run SimAdmin, so the static binary is copied in rather than
|
|
# installed through a package manager: no runtime deps, no apt state, trivially removable.
|
|
build-arm64: vendor
|
|
@mkdir -p dist
|
|
@CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags '$(LDFLAGS)' -o dist/msa-agent-linux-arm64 ./cmd/msa-agent
|
|
|
|
build-armv7: vendor
|
|
@mkdir -p dist
|
|
@CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -trimpath -ldflags '$(LDFLAGS)' -o dist/msa-agent-linux-armv7 ./cmd/msa-agent
|
|
|
|
clean:
|
|
@rm -rf dist
|