undocker/Makefile

51 lines
1.3 KiB
Makefile
Raw Normal View History

2021-08-24 14:23:31 +00:00
SCRIPTS = $(shell awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
2021-06-01 05:49:39 +00:00
GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
2021-06-01 06:07:32 +00:00
GOBIN = $(shell go env GOPATH)/bin/
GOOSARCHS = $(sort darwin/amd64 linux/amd64)
2021-08-24 03:47:38 +00:00
2021-08-24 10:57:30 +00:00
VSN ?= $(shell git describe --dirty)
2021-08-24 04:02:12 +00:00
VSNHASH = $(shell git rev-parse --verify HEAD)
LDFLAGS = -ldflags "-X main.Version=$(VSN) -X main.VersionHash=$(VSNHASH)"
undocker: ## builds binary for the current architecture
CGO_ENABLED=0 go build $(LDFLAGS) -o $@
2021-08-24 04:02:12 +00:00
.PHONY: test
test:
go test -race -cover ./...
2021-08-23 13:29:41 +00:00
define undockertarget
UNDOCKERS += undocker-$(1)-$(2)-$(VSN)
undocker-$(1)-$(2)-$(VSN): $(GODEPS)
2021-08-24 03:47:38 +00:00
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build $(LDFLAGS) -o $$@
2021-08-23 13:29:41 +00:00
endef
2021-08-23 13:32:00 +00:00
$(foreach goosarch,$(GOOSARCHS),\
$(eval $(call undockertarget,$(word 1,$(subst /, ,$(goosarch))),$(word 2,$(subst /, ,$(goosarch))))))
2021-06-01 16:54:55 +00:00
2021-08-23 13:29:41 +00:00
.PHONY: all
all: $(UNDOCKERS) sha256sum-$(VSN).txt
2021-06-01 06:00:27 +00:00
.PHONY: lint
2021-08-24 14:23:31 +00:00
lint:
2021-06-01 06:00:27 +00:00
go vet ./...
2021-06-01 06:10:10 +00:00
$(GOBIN)staticcheck -f stylish ./...
2021-08-24 14:23:31 +00:00
shellcheck $(SCRIPTS)
2021-06-01 05:42:23 +00:00
.INTERMEDIATE: coverage.out
2021-06-01 05:49:39 +00:00
coverage.out: $(GODEPS)
2021-06-01 05:42:23 +00:00
go test -coverprofile $@ ./...
coverage.html: coverage.out
go tool cover -html=$< -o $@
2021-06-01 16:54:55 +00:00
2021-08-29 04:48:31 +00:00
sha256sum-$(VSN).txt: $(UNDOCKERS)
2021-08-23 13:42:57 +00:00
sha256sum $(UNDOCKERS) > $@
2021-08-29 04:48:31 +00:00
sha256sum-$(VSN).txt.asc: sha256sum-$(VSN).txt
2021-08-23 13:42:57 +00:00
gpg --clearsign $<
2021-06-01 16:54:55 +00:00
.PHONY: clean
clean:
2021-08-29 04:48:31 +00:00
rm -f undocker-*-v* coverage.html sha256sum*.txt sha256sum*.txt.asc