Skip to content

Commit

Permalink
inject version from git tag
Browse files Browse the repository at this point in the history
Signed-off-by: sdghchj <[email protected]>
  • Loading branch information
sdghchj committed Jan 23, 2024
1 parent ae7e404 commit 681317a
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 681317a

Please sign in to comment.