-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using new build pattern for multi-arch builds on GHA.
- Loading branch information
Showing
3 changed files
with
131 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.ONESHELL: # Applies to every targets in the file! .ONESHELL instructs make to invoke a single instance of the shell and provide it with the entire recipe, regardless of how many lines it contains. | ||
|
||
######################################################################################################################## | ||
# Global Env Settings | ||
######################################################################################################################## | ||
BINARY_NAME = hatchet | ||
LD_FLAGS = | ||
ifdef STATIC | ||
LD_FLAGS := $(LD_FLAGS) -extldflags=-static | ||
endif | ||
ifdef GOOS | ||
BINARY_NAME := $(BINARY_NAME)-$(GOOS) | ||
LD_FLAGS := $(LD_FLAGS) -X main.goos=$(GOOS) | ||
endif | ||
ifdef GOARCH | ||
BINARY_NAME := $(BINARY_NAME)-$(GOARCH) | ||
LD_FLAGS := $(LD_FLAGS) -X main.goarch=$(GOARCH) | ||
endif | ||
ifdef GOARM | ||
BINARY_NAME := $(BINARY_NAME)-$(GOARM) | ||
endif | ||
ifeq ($(OS),Windows_NT) | ||
BINARY_NAME := $(BINARY_NAME).exe | ||
endif | ||
|
||
######################################################################################################################## | ||
# Binary | ||
######################################################################################################################## | ||
.PHONY: all | ||
all: build | ||
|
||
.PHONY: clean | ||
clean: | ||
go clean | ||
|
||
.PHONY: generate | ||
generate: dep | ||
go generate ./... | ||
|
||
.PHONY: dep | ||
dep: | ||
go mod vendor | ||
|
||
.PHONY: test | ||
test: dep | ||
go test -v -tags "static" ./... | ||
|
||
.PHONY: test-coverage | ||
test-coverage: dep | ||
go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" ./... | ||
|
||
.PHONY: build | ||
build: dep | ||
go build -ldflags "$(LD_FLAGS)" -o $(BINARY_NAME) -tags "static" ./cmd/hatchet | ||
ifneq ($(OS),Windows_NT) | ||
chmod +x $(BINARY_NAME) | ||
file $(BINARY_NAME) || true | ||
ldd $(BINARY_NAME) || true | ||
./$(BINARY_NAME) || true | ||
endif | ||
|
||
######################################################################################################################## | ||
# Docker | ||
######################################################################################################################## |