1
0
mirror of synced 2024-11-22 04:26:01 +03:00
mg-transport-telegram/Makefile
Alex Lushpai acb2a62da5
Initial release (#1)
Routes
Migrations
Settings form
Activation/deactivation through retailCRM/MG Transport API
2018-05-17 18:35:53 +03:00

35 lines
960 B
Makefile

ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR=$(ROOT_DIR)
CONFIG_FILE=$(ROOT_DIR)/config.yml
CONFIG_TEST_FILE=$(ROOT_DIR)/config_test.yml
BIN=$(ROOT_DIR)/mg-telegram
REVISION=$(shell git describe --tags 2>/dev/null || git log --format="v0.0-%h" -n 1 || echo "v0.0-unknown")
ifndef GOPATH
$(error GOPATH must be defined)
endif
export GOPATH := $(GOPATH):$(ROOT_DIR)
fmt:
@echo "==> Running gofmt"
@gofmt -l -s -w $(SRC_DIR)
install: fmt
@echo "==> Running go get"
$(eval DEPS:=$(shell cd $(SRC_DIR) \
&& go list -f '{{join .Imports "\n"}}{{ "\n" }}{{join .TestImports "\n"}}' ./... \
| sort | uniq | tr '\r' '\n' | paste -sd ' ' -))
@go get -d -v $(DEPS)
build: install
@echo "==> Building"
@go build -o $(BIN) -ldflags "-X common.build=${REVISION}" .
@echo $(BIN)
migrate: build
@${BIN} --config $(CONFIG_FILE) migrate -p ./migrations/
run: migrate
@echo "==> Running"
@${BIN} --config $(CONFIG_FILE) run