Skip to content

Commit

Permalink
build. add build flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed May 9, 2021
1 parent e7ecf60 commit 9e3fc9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

dst/
dist/
.dist
.idea/

# tls
Expand Down
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ before:
builds:
- id: ehco
main: ./cmd/ehco/main.go
flags:
- -trimpath
ldflags:
- -s -w -X github.com/Ehco1996/ehco/internal/constant/constant.Version=$(VERSION)
goarch:
- amd64
- arm64
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
NAME=ehco
BINDIR=.dist
VERSION=$(shell git describe --tags || echo "unknown version")
BUILDTIME=$(shell date -u)
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags='-s -w -X="github.com/Ehco1996/ehco/internal/constant/constant.Version=$(VERSION)"'

.PHONY: fmt test build tidy ensure release

fmt:
Expand All @@ -7,7 +13,7 @@ test:
go test -count=1 -coverpkg=./internal -timeout=10s ./...

build:
go build -o .dist/ehco cmd/ehco/main.go
${GOBUILD} -o $(BINDIR)/$(NAME) cmd/ehco/main.go

tidy:
cat go.mod | grep -v ' indirect' > direct.mod
Expand Down

0 comments on commit 9e3fc9f

Please sign in to comment.