mirror of
https://github.com/mitsuhiko/gh-issue-sync.git
synced 2026-09-14 20:26:44 +08:00
34 lines
961 B
Makefile
34 lines
961 B
Makefile
.PHONY: build test format install
|
|
|
|
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo dev)
|
|
LDFLAGS := -ldflags="-s -w -X main.version=$(VERSION)"
|
|
|
|
build:
|
|
go build $(LDFLAGS) -o gh-issue-sync ./cmd/gh-issue-sync
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
format:
|
|
go fmt ./...
|
|
|
|
install: build
|
|
@INSTALL_DIR=""; \
|
|
if command -v gh-issue-sync >/dev/null 2>&1; then \
|
|
INSTALL_DIR=$$(dirname $$(which gh-issue-sync)); \
|
|
else \
|
|
for dir in "$$HOME/.local/bin" "$$HOME/.bin" "$$HOME/bin"; do \
|
|
if [ -d "$$dir" ] && echo "$$PATH" | tr ':' '\n' | grep -qx "$$dir"; then \
|
|
INSTALL_DIR="$$dir"; \
|
|
break; \
|
|
fi; \
|
|
done; \
|
|
fi; \
|
|
if [ -z "$$INSTALL_DIR" ]; then \
|
|
echo "error: no suitable install directory found on PATH"; \
|
|
echo "hint: create ~/.local/bin and add it to your PATH"; \
|
|
exit 1; \
|
|
fi; \
|
|
cp gh-issue-sync "$$INSTALL_DIR/gh-issue-sync"; \
|
|
echo "installed to $$INSTALL_DIR/gh-issue-sync"
|