Skip to content

Commit

Permalink
chore: improve Makefile by moveing binary path duplicates into variab…
Browse files Browse the repository at this point in the history
…le (#122)
  • Loading branch information
matthiashermsen authored Jan 26, 2024
1 parent 93a3158 commit 292b2d0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ else
OPEN := xdg-open
endif

BINARY_NAME=get-next-version
MODULE_PATH=github.com/thenativeweb/${BINARY_NAME}

COMMON_FLAGS=-ldflags="-X '$(MODULE_PATH)/appversion.AppVersion=$(VERSION)'"

BUILD_DIR=./build

qa: analyze test

analyze:
Expand Down Expand Up @@ -35,16 +42,16 @@ build-auto: qa clean detect-version
@go build -ldflags="-X 'github.com/thenativeweb/get-next-version/version.Version=$(VERSION)'" -o ./build/get-next-version

build-darwin-amd64: qa clean detect-version
@GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'github.com/thenativeweb/get-next-version/version.Version=$(VERSION)'" -o ./build/get-next-version-darwin-amd64
@GOOS=darwin GOARCH=amd64 go build $(COMMON_FLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64

build-darwin-arm64: qa clean detect-version
@GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'github.com/thenativeweb/get-next-version/version.Version=$(VERSION)'" -o ./build/get-next-version-darwin-arm64
@GOOS=darwin GOARCH=arm64 go build $(COMMON_FLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64

build-linux-amd64: qa clean detect-version
@GOOS=linux GOARCH=amd64 go build -ldflags="-X 'github.com/thenativeweb/get-next-version/version.Version=$(VERSION)'" -o ./build/get-next-version-linux-amd64
@GOOS=linux GOARCH=amd64 go build $(COMMON_FLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64

build-windows-amd64: qa clean detect-version
@GOOS=windows GOARCH=amd64 go build -ldflags="-X 'github.com/thenativeweb/get-next-version/version.Version=$(VERSION)'" -o ./build/get-next-version-windows-amd64.exe
@GOOS=windows GOARCH=amd64 go build $(COMMON_FLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe

build: build-auto

Expand Down

0 comments on commit 292b2d0

Please sign in to comment.