Add release build targets for hf
This commit is contained in:
35
Makefile
Normal file
35
Makefile
Normal file
@@ -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
|
||||||
45
README.md
45
README.md
@@ -8,12 +8,24 @@
|
|||||||
go build -o ./bin/hf ./cmd/hf
|
go build -o ./bin/hf ./cmd/hf
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or use the bundled Makefile:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
To set the version at build time:
|
To set the version at build time:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -ldflags "-X git.hangman-lab.top/zhi/HarborForge.Cli/internal/commands.Version=1.0.0" -o ./bin/hf ./cmd/hf
|
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
|
## Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -53,13 +65,13 @@ Make sure `~/.local/bin` is on `PATH` before invoking `hf` directly.
|
|||||||
|
|
||||||
### OpenClaw profile install target
|
### 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
|
```text
|
||||||
~/.openclaw/bin/hf
|
~/.openclaw/bin/hf
|
||||||
```
|
```
|
||||||
|
|
||||||
Until that installer support lands, the equivalent manual install is:
|
If you want the equivalent manual install:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p "$HOME/.openclaw/bin"
|
mkdir -p "$HOME/.openclaw/bin"
|
||||||
@@ -100,6 +112,33 @@ hf task list
|
|||||||
hf task list --token "$HF_TOKEN"
|
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_<version>_<os>_<arch>
|
||||||
|
hf_<version>_<os>_<arch>.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
|
## Package Layout
|
||||||
|
|
||||||
```text
|
```text
|
||||||
@@ -189,5 +228,5 @@ There is not yet a finer-grained exit-code taxonomy; callers should currently tr
|
|||||||
### Pending
|
### Pending
|
||||||
|
|
||||||
- Backend code-based endpoint support (some commands still use id-based API routes)
|
- 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
|
- Integration tests
|
||||||
|
|||||||
Reference in New Issue
Block a user