fix: infer go bin path instead of hardcoding it

This commit is contained in:
Emanuel Casco 2026-05-07 09:24:22 +02:00
parent 22c0fd3571
commit 311ca26d76

View file

@ -1,6 +1,9 @@
.PHONY: build run test clean install release
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
GOBIN := $(shell go env GOBIN)
GOPATH := $(shell go env GOPATH)
INSTALL_DIR := $(if $(GOBIN),$(GOBIN),$(GOPATH)/bin)
build:
go build -ldflags "-X main.version=$(VERSION)" -o bin/ocgo ./cmd/ocgo
@ -15,7 +18,14 @@ clean:
rm -rf bin
install: build
<<<<<<< Updated upstream
install -m 0755 bin/ocgo $(HOME)/go/bin/ocgo
||||||| Stash base
install -m 0755 bin/ocgo $$(go env GOBIN)/ocgo
=======
mkdir -p "$(INSTALL_DIR)"
install -m 0755 bin/ocgo "$(INSTALL_DIR)/ocgo"
>>>>>>> Stashed changes
release:
@[ -n "$(TAG)" ] || (echo "Usage: make release TAG=v0.1.0" && exit 1)