2019-11-28 07:25:46 +01:00
|
|
|
BUILD ?= $(shell git rev-parse --short HEAD)
|
|
|
|
BUILD_DATE ?= $(shell git log -1 --format=%ci)
|
|
|
|
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
BUILD_VERSION ?= $(shell git describe --always --tags)
|
|
|
|
|
|
|
|
GOPATH ?= $(shell go env GOPATH)
|
|
|
|
|
|
|
|
ifndef GOPATH
|
|
|
|
override GOPATH = $(HOME)/go
|
|
|
|
endif
|
|
|
|
|
|
|
|
export GO111MODULE := on
|
|
|
|
|
|
|
|
# Build-time Go variables
|
2020-04-16 06:26:32 +02:00
|
|
|
version = github.com/dosco/super-graph/internal/serv.version
|
|
|
|
gitBranch = github.com/dosco/super-graph/internal/serv.gitBranch
|
|
|
|
lastCommitSHA = github.com/dosco/super-graph/internal/serv.lastCommitSHA
|
|
|
|
lastCommitTime = github.com/dosco/super-graph/internal/serv.lastCommitTime
|
2019-11-28 07:25:46 +01:00
|
|
|
|
|
|
|
BUILD_FLAGS ?= -ldflags '-s -w -X ${lastCommitSHA}=${BUILD} -X "${lastCommitTime}=${BUILD_DATE}" -X "${version}=${BUILD_VERSION}" -X ${gitBranch}=${BUILD_BRANCH}'
|
|
|
|
|
2019-11-28 21:27:20 +01:00
|
|
|
.PHONY: all build gen clean test run lint changlog release version help $(PLATFORMS)
|
2019-11-28 07:25:46 +01:00
|
|
|
|
2019-11-29 06:09:50 +01:00
|
|
|
test:
|
2020-05-10 17:26:48 +02:00
|
|
|
@go test -v -short -race ./...
|
2019-11-28 07:25:46 +01:00
|
|
|
|
|
|
|
BIN_DIR := $(GOPATH)/bin
|
2020-01-11 23:15:39 +01:00
|
|
|
GORICE := $(BIN_DIR)/rice
|
2019-11-28 07:25:46 +01:00
|
|
|
GOLANGCILINT := $(BIN_DIR)/golangci-lint
|
2019-11-28 21:27:20 +01:00
|
|
|
GITCHGLOG := $(BIN_DIR)/git-chglog
|
2020-04-16 06:26:32 +02:00
|
|
|
WEB_BUILD_DIR := ./internal/serv/web/build/manifest.json
|
2019-11-28 21:27:20 +01:00
|
|
|
|
|
|
|
$(GORICE):
|
|
|
|
@GO111MODULE=off go get -u github.com/GeertJohan/go.rice/rice
|
|
|
|
|
2020-01-11 23:15:39 +01:00
|
|
|
$(WEB_BUILD_DIR):
|
2020-04-10 08:27:43 +02:00
|
|
|
@echo "First install Yarn and create a build of the web UI then re-run make install"
|
2020-04-16 06:26:32 +02:00
|
|
|
@echo "Run this command: yarn --cwd internal/serv/web/ build"
|
2020-01-11 23:15:39 +01:00
|
|
|
@exit 1
|
|
|
|
|
2019-11-28 21:27:20 +01:00
|
|
|
$(GITCHGLOG):
|
2020-05-04 03:01:16 +02:00
|
|
|
@GO111MODULE=off go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
|
2019-11-28 21:27:20 +01:00
|
|
|
|
|
|
|
changelog: $(GITCHGLOG)
|
|
|
|
@git-chglog $(ARGS)
|
2019-11-28 07:25:46 +01:00
|
|
|
|
|
|
|
$(GOLANGCILINT):
|
2020-05-01 08:20:13 +02:00
|
|
|
@GO111MODULE=off curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOPATH)/bin v1.25.1
|
2019-11-28 07:25:46 +01:00
|
|
|
|
2019-12-29 07:53:54 +01:00
|
|
|
lint: $(GOLANGCILINT)
|
2019-11-28 07:25:46 +01:00
|
|
|
@golangci-lint run ./... --skip-dirs-use-default
|
|
|
|
|
|
|
|
BINARY := super-graph
|
|
|
|
LDFLAGS := -s -w
|
|
|
|
PLATFORMS := windows linux darwin
|
|
|
|
os = $(word 1, $@)
|
|
|
|
|
2020-01-11 23:15:39 +01:00
|
|
|
$(PLATFORMS): lint test
|
2019-11-28 07:25:46 +01:00
|
|
|
@mkdir -p release
|
2020-04-16 06:26:32 +02:00
|
|
|
@GOOS=$(os) GOARCH=amd64 go build $(BUILD_FLAGS) -o release/$(BINARY)-$(BUILD_VERSION)-$(os)-amd64 main.go
|
2019-11-28 07:25:46 +01:00
|
|
|
|
|
|
|
release: windows linux darwin
|
|
|
|
|
2019-11-29 06:09:50 +01:00
|
|
|
all: lint test $(BINARY)
|
2019-11-28 07:25:46 +01:00
|
|
|
|
|
|
|
build: $(BINARY)
|
|
|
|
|
2020-01-11 23:15:39 +01:00
|
|
|
gen: $(GORICE) $(WEB_BUILD_DIR)
|
2019-11-28 07:25:46 +01:00
|
|
|
@go generate ./...
|
|
|
|
|
2020-01-11 23:15:39 +01:00
|
|
|
$(BINARY): clean
|
2020-04-16 06:26:32 +02:00
|
|
|
@go build $(BUILD_FLAGS) -o $(BINARY) main.go
|
2019-11-28 07:25:46 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -f $(BINARY)
|
|
|
|
|
|
|
|
run: clean
|
|
|
|
@go run $(BUILD_FLAGS) main.go $(ARGS)
|
|
|
|
|
2020-04-13 06:50:54 +02:00
|
|
|
install: clean build
|
2019-11-28 07:25:46 +01:00
|
|
|
@echo "Commit Hash: `git rev-parse HEAD`"
|
|
|
|
@echo "Old Hash: `shasum $(GOPATH)/bin/$(BINARY) 2>/dev/null | cut -c -32`"
|
2020-04-13 06:50:54 +02:00
|
|
|
@mv $(BINARY) $(GOPATH)/bin/$(BINARY)
|
2019-11-28 07:25:46 +01:00
|
|
|
@echo "New Hash:" `shasum $(GOPATH)/bin/$(BINARY) 2>/dev/null | cut -c -32`
|
|
|
|
|
|
|
|
uninstall: clean
|
|
|
|
@go clean -i -x
|
|
|
|
|
|
|
|
version:
|
|
|
|
@echo Super Graph ${BUILD_VERSION}
|
|
|
|
@echo Build: ${BUILD}
|
|
|
|
@echo Build date: ${BUILD_DATE}
|
|
|
|
@echo Branch: ${BUILD_BRANCH}
|
|
|
|
@echo Go version: $(shell go version)
|
|
|
|
|
|
|
|
help:
|
|
|
|
@echo
|
|
|
|
@echo Build commands:
|
|
|
|
@echo " make build - Build supergraph binary"
|
|
|
|
@echo " make install - Install supergraph binary"
|
|
|
|
@echo " make uninstall - Uninstall supergraph binary"
|
|
|
|
@echo " make [platform] - Build for platform [linux|darwin|windows]"
|
|
|
|
@echo " make release - Build all platforms"
|
2019-11-28 21:27:20 +01:00
|
|
|
@echo " make run - Run supergraph (eg. make run ARGS=\"help\")"
|
|
|
|
@echo " make test - Run all tests"
|
|
|
|
@echo " make changelog - Generate changelog (eg. make changelog ARGS=\"help\")"
|
2019-11-28 07:25:46 +01:00
|
|
|
@echo " make help - This help"
|
|
|
|
@echo
|