woj-server/Makefile

38 lines
876 B
Makefile

GO := go
PKG_BASE := $(shell head -n 1 go.mod | awk '{print $$2}')
BUILD_TIME := $(shell date -u '+%Y%m%d-%I%M%S')
VERSION := $(shell cat VERSION)
GIT_COMMIT := $(shell git rev-parse HEAD)
LDFLAGS += -X $(PKG_BASE)/cmd.BuildTime=$(BUILD_TIME)
LDFLAGS += -X $(PKG_BASE)/cmd.Version=$(VERSION)
LDFLAGS += -X $(PKG_BASE)/cmd.GitCommit=$(GIT_COMMIT)
LDFLAGS += -X $(PKG_BASE)/cmd.SentryDSN=$(shell cat dsn.txt)
LDFLAGS += -s -w
GOBUILD := $(GO) build -ldflags '$(LDFLAGS)'
GOBIN := $(shell go env GOPATH)/bin
.PHONY: all build clean dep swagger fmt
default: all
all: clean build
build: swagger dep
$(GOBUILD) -o woj ./cmd/woj
clean:
rm -f woj
dep:
go mod download
swagger:
go install github.com/swaggo/swag/cmd/swag@latest
$(GOBIN)/swag init -g internal/web/router/api.go -d .,./internal/e,./internal/model --pdl 1 -o internal/web/router/docs
fmt:
go fmt ./...