Skip to content

Commit

Permalink
goreleaser ldflags
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>
  • Loading branch information
jdolitsky committed Jan 14, 2019
1 parent d2a3be5 commit 51feb36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ builds:
binary: ./chart-scanner
env:
- CGO_ENABLED=0
ldflags:
- -w -X main.version={{.Version}} -X main.revision={{.ShortCommit}}
goos:
- darwin
- linux
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ build: build-linux build-mac build-windows

build-windows:
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -v \
--ldflags="-w -X main.version=$(VERSION) -X main.revision=$(REVISION)" \
--ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/windows/amd64/$(CLI_EXE) $(CLI_PKG) # windows

build-linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v \
--ldflags="-w -X main.version=$(VERSION) -X main.revision=$(REVISION)" \
--ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/amd64/$(CLI_EXE) $(CLI_PKG) # linux

build-mac:
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -v \
--ldflags="-w -X main.version=$(VERSION) -X main.revision=$(REVISION)" \
--ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/darwin/amd64/$(CLI_EXE) $(CLI_PKG) # mac osx

.PHONY: clean
Expand Down
6 changes: 3 additions & 3 deletions cmd/chart-scanner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

var (
// Version is the semantic version (added at compile time)
version string
Version string

// Revision is the git commit id (added at compile time)
revision string
Revision string

exitCode int
)
Expand All @@ -25,7 +25,7 @@ func main() {
log.SetOutput(os.Stdout)
app := cli.NewApp()
app.Name = "chart-scanner"
app.Version = fmt.Sprintf("%s (build %s)", version, revision[0:6])
app.Version = fmt.Sprintf("%s (build %s)", Version, Revision)
app.Usage = "checks a storage directory for evil charts"
app.Flags = buildCliFlags()
app.Action = cliHandler
Expand Down

0 comments on commit 51feb36

Please sign in to comment.