From 912b1e7bfa242b5de016d07581525e16d2bcde7a Mon Sep 17 00:00:00 2001 From: Kevin Tang <73975146+vt128@users.noreply.github.com> Date: Tue, 23 Jun 2026 13:45:56 +0800 Subject: [PATCH] [build] Makefile: align GoVersion + add a `snapshot` target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GoVersion is now injected from `go env GOVERSION` (e.g. go1.25.9) instead of the full `go version` string. The old value baked the build *host* platform, so a `make build_linux` binary misleadingly reported `darwin/arm64`; the new value is the toolchain version only and matches what GoReleaser injects. - Add `make snapshot`: a release-style cross-platform build via GoReleaser in --snapshot mode (local dry-run, nothing published). `make build` stays the fast single-platform dev build; `make snapshot` is for inspecting what a real release would ship. Named `snapshot` (not `release`) on purpose — a real release only ever happens via a tag + the release workflow, never a local make. --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 47cbb59..75dce1e 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,10 @@ GOMOD=$(GOCMD) mod export CGO_ENABLED=0 export TZ=Asia/Shanghai export PACK=github.com/1set/starcli/config -export FLAGS="-s -w -X '$(PACK).AppName=$(BINARY)' -X '$(PACK).BuildDate=`date '+%Y-%m-%dT%T%z'`' -X '$(PACK).BuildHost=`hostname`' -X '$(PACK).GoVersion=`go version`' -X '$(PACK).GitBranch=`git symbolic-ref -q --short HEAD`' -X '$(PACK).GitCommit=`git rev-parse --short HEAD`' -X '$(PACK).GitSummary=$${GIT_TAG_NAME:-`git describe --tags --dirty --always`}' -X '$(PACK).CIBuildNum=${BUILD_NUM}'" +export FLAGS="-s -w -X '$(PACK).AppName=$(BINARY)' -X '$(PACK).BuildDate=`date '+%Y-%m-%dT%T%z'`' -X '$(PACK).BuildHost=`hostname`' -X '$(PACK).GoVersion=`go env GOVERSION`' -X '$(PACK).GitBranch=`git symbolic-ref -q --short HEAD`' -X '$(PACK).GitCommit=`git rev-parse --short HEAD`' -X '$(PACK).GitSummary=$${GIT_TAG_NAME:-`git describe --tags --dirty --always`}' -X '$(PACK).CIBuildNum=${BUILD_NUM}'" # commands -.PHONY: default build build_linux build_mac build_windows run install ci test bench +.PHONY: default build build_linux build_mac build_windows snapshot run install ci test bench default: @echo "build target is required for $(BINARY)" @exit 1 @@ -47,6 +47,12 @@ build_mac: build_windows: GOOS=windows GOARCH=amd64 $(GOBUILD) -v -ldflags $(FLAGS) -trimpath -o $(BINARY).exe . +# Release-style cross-platform build via GoReleaser (snapshot = local dry-run, +# nothing is published). Inspect the artifacts under dist/. `make build` stays +# the fast single-platform dev build; this is for checking what a release ships. +snapshot: + GOVERSION=`go env GOVERSION` $(GORUN) github.com/goreleaser/goreleaser/v2@latest release --snapshot --clean + run: build ./$(BINARY)