Files
laily 56a189e678 ci: add cross-platform release workflow with version injection
Build linux/darwin amd64 and arm64 artifacts on push, upload GitHub
Release assets on v* tags, and expose version via agent-notify version.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 12:50:26 +08:00

29 lines
794 B
Makefile

.PHONY: build test install cross
BINARY := agent-notify
VERSION ?= dev
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)
build:
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/agent-notify
test:
go test ./...
install: build
install -m 755 bin/$(BINARY) $(HOME)/.local/bin/$(BINARY)
cross:
@mkdir -p dist
@for target in \
"linux amd64" \
"linux arm64" \
"darwin amd64" \
"darwin arm64"; do \
set -- $$target; \
out=dist/$(BINARY)-$(VERSION)_$$1_$$2; \
echo "building $$out"; \
GOOS=$$1 GOARCH=$$2 CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o "$$out" ./cmd/agent-notify; \
done