Skip to content

Commit

Permalink
Added ldflags to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-rc committed Apr 28, 2022
1 parent 041c99d commit 7e349e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version={{.Version}}
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version=v{{.Version}}
goos:
- linux
- darwin
Expand All @@ -18,7 +18,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version={{.Version}}
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version=v{{.Version}}
goos:
- linux
- darwin
Expand All @@ -34,7 +34,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version={{.Version}}
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version=v{{.Version}}
goos:
- linux
- darwin
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PROJECT := dateilager
VERSION := $(shell git describe --tags --abbrev=0)
BUILD_FLAGS := -ldflags="-s -w -X github.com/gadget-inc/dateilager/pkg/version.Version=$(VERSION)"

DB_HOST ?= 127.0.0.1
DB_USER ?= postgres
Expand Down Expand Up @@ -49,7 +51,7 @@ internal/pb/%_grpc.pb.go: internal/pb/%.proto
protoc --experimental_allow_proto3_optional --go-grpc_out=. --go-grpc_opt=paths=source_relative $^

bin/%: cmd/%/main.go $(PKG_GO_FILES) $(INTERNAL_GO_FILES) go.sum
CGO_ENABLED=0 go build -o $@ $<
CGO_ENABLED=0 go build $(BUILD_FLAGS) -o $@ $<

js/src/%.client.ts: internal/pb/%.proto
cd js && npx protoc --experimental_allow_proto3_optional --ts_out ./src --ts_opt long_type_bigint --proto_path ../internal/pb/ ../$^
Expand All @@ -62,13 +64,13 @@ dev/server.cert: dev/server.key
build: internal/pb/fs.pb.go internal/pb/fs_grpc.pb.go bin/server bin/client bin/webui js/src/fs.client.ts dev/server.cert

release/%_linux_amd64: cmd/%/main.go $(PKG_GO_FILES) $(INTERNAL_GO_FILES) go.sum
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $<
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ $<

release/%_macos_amd64: cmd/%/main.go $(PKG_GO_FILES) $(INTERNAL_GO_FILES) go.sum
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $@ $<
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ $<

release/%_macos_arm64: cmd/%/main.go $(PKG_GO_FILES) $(INTERNAL_GO_FILES) go.sum
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $@ $<
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(BUILD_FLAGS) -o $@ $<

release/migrations.tar.gz: migrations/*
tar -zcf $@ migrations
Expand Down

0 comments on commit 7e349e9

Please sign in to comment.