Improve Makefile #1

Open
opened 2025-10-16 07:14:21 +00:00 by mpeterma · 0 comments
Owner
PRODUCT = "pulsar-sentinel"
#BUILD_TAG = `git describe --tag`
BUILD_TAG = 'v0.9.0'
TAG = $(shell echo $(BUILD_TAG) | sed s/^v//)
ARCH = $(shell go env GOARCH)
OS = $(shell go env GOOS)

build: 
	CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -ldflags "-X main.Version=$(BUILD_TAG)"

package: build
	mkdir -p dist/$(PRODUCT)-$(TAG)-$(OS)-$(ARCH)
	cp $(PRODUCT) dist/$(PRODUCT)-$(TAG)-$(OS)-$(ARCH)/
	cp README.md dist/$(PRODUCT)-$(TAG)-$(OS)-$(ARCH)/
	tar -czvf $(PRODUCT)-$(TAG)-$(OS)-$(ARCH).tar.gz -C dist $(PRODUCT)-$(TAG)-$(OS)-$(ARCH)

clean:
	rm -rf dist $(PRODUCT) *.tar.gz

all: package

.DEFAULT_GOAL := all
.PHONY: all build package clean
```Makefile PRODUCT = "pulsar-sentinel" #BUILD_TAG = `git describe --tag` BUILD_TAG = 'v0.9.0' TAG = $(shell echo $(BUILD_TAG) | sed s/^v//) ARCH = $(shell go env GOARCH) OS = $(shell go env GOOS) build: CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -ldflags "-X main.Version=$(BUILD_TAG)" package: build mkdir -p dist/$(PRODUCT)-$(TAG)-$(OS)-$(ARCH) cp $(PRODUCT) dist/$(PRODUCT)-$(TAG)-$(OS)-$(ARCH)/ cp README.md dist/$(PRODUCT)-$(TAG)-$(OS)-$(ARCH)/ tar -czvf $(PRODUCT)-$(TAG)-$(OS)-$(ARCH).tar.gz -C dist $(PRODUCT)-$(TAG)-$(OS)-$(ARCH) clean: rm -rf dist $(PRODUCT) *.tar.gz all: package .DEFAULT_GOAL := all .PHONY: all build package clean ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Atlas/pulsar-sentinel#1
No description provided.