| index b695aad..0e99e22 100644 |
| --- a/Makefile |
| +++ b/Makefile |
| @@ -1,4 +1,4 @@ |
| -.PHONY: build test test-vet test-fmt test-build test-migrations test-go test-race |
| +.PHONY: build release test test-vet test-fmt test-build test-migrations test-go test-race |
| |
| # One binary, CGO_ENABLED=0, cgo-free SQLite (AGENTS.md / Deploys). Set |
| # per-target below rather than exported globally, because test-race is |
| @@ -6,6 +6,24 @@ |
| build: |
| CGO_ENABLED=0 go build ./... |
| |
| +# The ONLY way a binary should be built for shipping. rastrillo's |
| +# BuildVersion defaults to "dev", and an unstamped binary answers |
| +# GET /api/version with "dev" — which is the field used to tell what is |
| +# actually deployed, so an unstamped release makes the fleet unreadable |
| +# while still looking like a successful deploy. Shipping one by hand |
| +# with a plain `go build` is exactly the mistake this target removes. |
| +# |
| +# A dirty tree is refused: the sha would name a commit that is not what |
| +# is in the binary, which is worse than no stamp at all. |
| +RELEASE_OUT ?= ./sheets-arm64 |
| +release: |
| + @git diff --quiet && git diff --cached --quiet || \ |
| + { echo "refusing to build a release from a dirty tree"; exit 1; } |
| + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath \ |
| + -ldflags "-s -w -X github.com/carlosframework/rastrillo.BuildVersion=$$(git rev-parse --short HEAD)" \ |
| + -o $(RELEASE_OUT) ./cmd/sheets |
| + @echo "built $(RELEASE_OUT) stamped $$(git rev-parse --short HEAD)" |
| + |
| # The gate, split into named targets so CI can report them individually |
| # (.amadan/ci.d calls these one at a time, each its own step). `make |
| # test` runs exactly the same six things in the same order, so the |