Skip to content

🪙 feat(cli): add for env/LSP/provider readiness #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Portable ops Makefile for opencode TUI
# Usage:
# make lint # gofmt + vet
# make build # build CLI to packages/tui/opencode
# make smoke # --version + health
# make ci-local # lint + smoke
# make release # build versioned bin + sha256 (local artifacts/)
# make clean # remove local build artifacts

SHELL := /bin/bash
GOFLAGS ?=
GOWORK ?= off
export GOWORK

VERSION ?= 0.4.46
COMMIT := $(shell git rev-parse --short=12 HEAD)
LDV := -s -w -X main.Version=$(VERSION) -X main.Commit=$(COMMIT)

PKG_DIR := packages/tui
BIN_DIR := tools/opencode-bin
OUT_BIN := $(BIN_DIR)/opencode-v$(VERSION)

.PHONY: lint build smoke ci-local release clean

lint:
@cd $(PKG_DIR); \
out=$$(gofmt -l . || true); \
if [ -n "$$out" ]; then echo "gofmt issues (warning):"; echo "$$out"; fi; \
go vet ./...

build:
@mkdir -p $(BIN_DIR)
@cd $(PKG_DIR); \
GOFLAGS="$(GOFLAGS)" go mod download; \
GOFLAGS="$(GOFLAGS)" go build -trimpath -ldflags "$(LDV)" -o ./opencode ./cmd/opencode

smoke: build
@cd $(PKG_DIR); \
./opencode --version; \
./opencode health | sed -n 1,25p

ci-local: lint smoke

release:
@mkdir -p $(BIN_DIR) artifacts
@cd $(PKG_DIR); \
GOFLAGS="$(GOFLAGS)" go mod download; \
GOFLAGS="$(GOFLAGS)" go build -trimpath -ldflags "$(LDV)" -o ../../$(OUT_BIN) ./cmd/opencode
@shasum -a 256 $(OUT_BIN) | tee artifacts/opencode-v$(VERSION).sha256 >/dev/null

clean:
@rm -f $(PKG_DIR)/opencode $(OUT_BIN) artifacts/opencode-v$(VERSION).sha256 2>/dev/null || true

RELEASE_PLATFORMS := darwin/arm64 darwin/amd64 linux/arm64 linux/amd64

release-all:
@mkdir -p $(BIN_DIR) artifacts
@cd $(PKG_DIR); \
LDV="-s -w -X main.Version=$(VERSION) -X main.Commit=$$(git -C .. rev-parse --short=12 HEAD)"; \
for T in $(RELEASE_PLATFORMS); do \
GOOS=$${T%/*} GOARCH=$${T#*/} CGO_ENABLED=0 \
go build -trimpath -ldflags "$$LDV" \
-o ../../$(BIN_DIR)/opencode-$$GOOS-$$GOARCH ./cmd/opencode; \
echo "built $(BIN_DIR)/opencode-$$GOOS-$$GOARCH"; \
done
@for f in $(BIN_DIR)/opencode-*; do \
shasum -a 256 $$f | tee artifacts/$$(basename $$f).sha256; \
done
@echo "Release build complete: $(BIN_DIR) + checksums in artifacts/"