From b3063733a9f8130ef13de24297c1daa98cf7cce2 Mon Sep 17 00:00:00 2001 From: zhi Date: Sat, 21 Mar 2026 20:32:28 +0000 Subject: [PATCH] Add release build targets for hf --- Makefile | 35 +++++++++++++++++++++++++++++++++++ README.md | 45 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8636db1 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +VERSION ?= dev +BINARY := hf +MAIN_PKG := ./cmd/hf +LDFLAGS := -X git.hangman-lab.top/zhi/HarborForge.Cli/internal/commands.Version=$(VERSION) +DIST_DIR := dist +RELEASE_TARGETS := \ + linux/amd64 \ + linux/arm64 \ + darwin/amd64 \ + darwin/arm64 \ + windows/amd64 + +.PHONY: build clean release release-all + +build: + mkdir -p bin + go build -ldflags "$(LDFLAGS)" -o ./bin/$(BINARY) $(MAIN_PKG) + +clean: + rm -rf ./bin/$(BINARY) ./$(DIST_DIR) + +release: clean + mkdir -p $(DIST_DIR) + @set -e; \ + for target in $(RELEASE_TARGETS); do \ + os=$${target%/*}; \ + arch=$${target#*/}; \ + ext=""; \ + if [ "$$os" = "windows" ]; then ext=".exe"; fi; \ + out="$(DIST_DIR)/$(BINARY)_$(VERSION)_$${os}_$${arch}$${ext}"; \ + echo "==> Building $$out"; \ + GOOS=$$os GOARCH=$$arch go build -ldflags "$(LDFLAGS)" -o "$$out" $(MAIN_PKG); \ + done + +release-all: release diff --git a/README.md b/README.md index e62e1f3..2bcf630 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,24 @@ go build -o ./bin/hf ./cmd/hf ``` +Or use the bundled Makefile: + +```bash +make build +``` + To set the version at build time: ```bash go build -ldflags "-X git.hangman-lab.top/zhi/HarborForge.Cli/internal/commands.Version=1.0.0" -o ./bin/hf ./cmd/hf ``` +The Makefile versioned equivalent is: + +```bash +make build VERSION=1.0.0 +``` + ## Run ```bash @@ -53,13 +65,13 @@ Make sure `~/.local/bin` is on `PATH` before invoking `hf` directly. ### OpenClaw profile install target -The planned OpenClaw plugin installer flow will place the binary at: +The OpenClaw plugin installer flow places the binary at: ```text ~/.openclaw/bin/hf ``` -Until that installer support lands, the equivalent manual install is: +If you want the equivalent manual install: ```bash mkdir -p "$HOME/.openclaw/bin" @@ -100,6 +112,33 @@ hf task list hf task list --token "$HF_TOKEN" ``` +## Release Packaging + +Cross-platform release builds are available through the Makefile: + +```bash +make release VERSION=1.0.0 +``` + +This produces versioned artifacts in `dist/` using a stable naming pattern: + +```text +hf___ +hf___.exe # Windows +``` + +Current release targets: +- `linux/amd64` +- `linux/arm64` +- `darwin/amd64` +- `darwin/arm64` +- `windows/amd64` + +Examples: +- `dist/hf_1.0.0_linux_amd64` +- `dist/hf_1.0.0_darwin_arm64` +- `dist/hf_1.0.0_windows_amd64.exe` + ## Package Layout ```text @@ -189,5 +228,5 @@ There is not yet a finer-grained exit-code taxonomy; callers should currently tr ### Pending - Backend code-based endpoint support (some commands still use id-based API routes) -- Cross-platform binary packaging / release pipeline +- Release automation beyond local `make release` packaging (checksums / archives / CI publishing) - Integration tests