Skip to content

Commit

Permalink
chore: build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Oct 6, 2023
1 parent aa6dfb9 commit 71e473c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NAME=canary-checker
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH = $(shell uname -m | sed 's/x86_64/amd64/')
KUSTOMIZE=$(PWD)/.bin/kustomize

LD_FLAGS=-ldflags "-w -s -X \"main.version=$(VERSION_TAG)\""
ifeq ($(VERSION),)
VERSION_TAG=$(shell git describe --abbrev=0 --tags || echo latest)
else
Expand Down Expand Up @@ -108,21 +108,25 @@ docker-push:

.PHONY: compress
compress: .bin/upx
upx -5 ./.bin/$(NAME)_linux_amd64 ./.bin/$(NAME)_linux_arm64 ./.bin/$(NAME)_darwin_amd64 ./.bin/$(NAME)_darwin_arm64 ./.bin/$(NAME).exe
upx -5 ./.bin/$(NAME)_linux_amd64 ./.bin/$(NAME)_linux_arm64 ./.bin/$(NAME)_darwin_amd64 ./.bin/$(NAME)_darwin_arm64 ./.bin/$(NAME).exe ./.bin/$(NAME) ./.bin/$(NAME).test

.PHONY: compress-build
compress-build: .bin/upx
upx -5 ./.bin/$(NAME) ./.bin/$(NAME).test

.PHONY: linux
linux:
GOOS=linux GOARCH=amd64 go build -o ./.bin/$(NAME)_linux_amd64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
GOOS=linux GOARCH=arm64 go build -o ./.bin/$(NAME)_linux_arm64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
GOOS=linux GOARCH=amd64 go build -o ./.bin/$(NAME)_linux_amd64 $(LD_FLAGS) main.go
GOOS=linux GOARCH=arm64 go build -o ./.bin/$(NAME)_linux_arm64 $(LD_FLAGS) main.go

.PHONY: darwin
darwin:
GOOS=darwin GOARCH=amd64 go build -o ./.bin/$(NAME)_darwin_amd64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
GOOS=darwin GOARCH=arm64 go build -o ./.bin/$(NAME)_darwin_arm64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
GOOS=darwin GOARCH=amd64 go build -o ./.bin/$(NAME)_darwin_amd64 $(LD_FLAGS) main.go
GOOS=darwin GOARCH=arm64 go build -o ./.bin/$(NAME)_darwin_arm64 $(LD_FLAGS) main.go

.PHONY: windows
windows:
GOOS=windows GOARCH=amd64 go build -o ./.bin/$(NAME).exe -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
GOOS=windows GOARCH=amd64 go build -o ./.bin/$(NAME).exe $(LD_FLAGS) main.go

.PHONY: binaries
binaries: linux darwin windows compress
Expand Down Expand Up @@ -162,16 +166,16 @@ dev:

.PHONY: build
build:
go build -o ./.bin/$(NAME) -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
go build -o ./.bin/$(NAME) $(LD_FLAGS) main.go

.PHONY: test-build
test-build:
go test test/... -o ./.bin/$(NAME).test -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
go test test/... -o ./.bin/$(NAME).test $(LD_FLAGS) main.go


.PHONY: fast-build
fast-build:
go build --tags fast -o ./.bin/$(NAME) -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
go build --tags fast -o ./.bin/$(NAME) $(LD_FLAGS) main.go

.PHONY: install
install:
Expand Down
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME=canary-checker
LDFLAGS=-ldflags "-X \"main.version=$(VERSION_TAG)\""
LD_FLAGS=-ldflags "-w -s -X \"main.version=$(VERSION_TAG)\""

ifeq ($(VERSION),)
VERSION_TAG=$(shell git describe --abbrev=0 --tags || echo latest)
Expand Down

0 comments on commit 71e473c

Please sign in to comment.