Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inject version from git tag #1747

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ GOCMD:=$(shell which go)
GOLINT:=$(shell which golint)
GOIMPORT:=$(shell which goimports)
GOFMT:=$(shell which gofmt)
GIT:=$(shell which git)
GOBUILD:=$(GOCMD) build
GOINSTALL:=$(GOCMD) install
GOCLEAN:=$(GOCMD) clean
Expand All @@ -11,6 +12,11 @@ GOGET:=$(GOCMD) get
GOLIST:=$(GOCMD) list
GOVET:=$(GOCMD) vet
GOPATH:=$(shell $(GOCMD) env GOPATH)
LDFLAGS:="-w -s"
VERSION:= $(shell $(GIT) describe --tags --exact-match)
ifneq ($(VERSION),)
LDFLAGS="$(LDFLAGS) -X 'swag.version=$(VERSION)'"
endif
u := $(if $(update),-u)

BINARY_NAME:=swag
Expand All @@ -23,7 +29,7 @@ all: test build

.PHONY: build
build: deps
$(GOBUILD) -o $(BINARY_NAME) ./cmd/swag
$(GOBUILD) -ldflags $(LDFLAGS) -o $(BINARY_NAME) ./cmd/swag

.PHONY: install
install: deps
Expand Down