Shutdown Tool to shutdown Raspberry Pi remotely.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

PKGS := $(shell go list ./... | grep -v /vendor)
GO_FILES := $(shell find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/
BINARY := shutdown-tool
PLATFORM := linux
ARCHS := amd64 arm arm64
VERSION ?= latest
arch = $(word 1, $@)
@mkdir -p release
go get # Linter
go get # Badass static analyzer/linter
go get # Cyclomatic complexity check
go test -v -race $(PKGS) # Normal Test
go vet ./... # go vet is the official Go static analyzer
staticcheck ./... # "go vet on steroids" + linter
gocyclo -over 19 $(GO_FILES) # forbid code with huge functions
golint -set_exit_status $(PKGS) # one last linter
GOARCH=$(arch) GOOS=$(PLATFORM) go build -ldflags '-s -w -X main.version=$(VERSION)' -o release/$(BINARY) ./cmd/$(BINARY)
tar -cf release/$(BINARY)-$(VERSION)-linux-$(arch).tar -C release $(BINARY)
tar -uf release/$(BINARY)-$(VERSION)-linux-$(arch).tar -C scripts
tar -uf release/$(BINARY)-$(VERSION)-linux-$(arch).tar -C init/systemd shutdown-tool.service
gzip -f release/$(BINARY)-$(VERSION)-linux-$(arch).tar
rm release/$(BINARY)
.PHONY: release
release: arm arm64 amd64
rm -rf release/*
all: bootstrap test release