-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 1.81 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# some housekeeping tasks
#
# variable definitions
NAME := certcal
DESC := provide an iCal web feed for certificate expiration
PREFIX ?= usr/local
VERSION := $(shell git describe --tags --always --dirty)
GOVERSION := $(shell go version)
BUILD_GOOS ?= $(shell go env GOOS)
BUILD_GOARCH ?= $(shell go env GOARCH)
RELEASE_ARTIFACTS_DIR := .release_artifacts
CHECKSUM_FILE := checksums.txt
$(RELEASE_ARTIFACTS_DIR):
install -d $@
BUILDER := $(shell echo "${BUILDER_NAME} <${EMAIL}>")
PKG_RELEASE ?= 1
PROJECT_URL := "https://github.com/mrtazz/$(NAME)"
LDFLAGS := -X 'main.version=$(VERSION)' \
-X 'main.goversion=$(GOVERSION)'
TARGETS := certcal
INSTALLED_TARGETS = $(addprefix $(PREFIX)/bin/, $(TARGETS))
.PHONY: certcal
certcal: certcal.go
GOOS=$(BUILD_GOOS) GOARCH=$(BUILD_GOARCH) go build -ldflags "$(LDFLAGS)" -o $@ $<
.DEFAULT_GOAL:=certcal
# development tasks
.PHONY: test
test:
go test -v ./...
.PHONY: coverage
coverage:
go test -v -race -coverprofile=cover.out ./...
@-go tool cover -html=cover.out -o cover.html
.PHONY: benchmark
benchmark:
@echo "Running tests..."
@go test -bench=. ${NAME}
# install tasks
$(PREFIX)/bin/%: %
install -d $$(dirname $@)
install -m 755 $< $@
.PHONY: install
install: $(INSTALLED_TARGETS) $(INSTALLED_MAN_TARGETS)
.PHONY: local-install
local-install:
$(MAKE) install PREFIX=usr/local
.PHONY: build-artifact
build-artifact: certcal $(RELEASE_ARTIFACTS_DIR)
mv certcal $(RELEASE_ARTIFACTS_DIR)/certcal-$(VERSION).$(BUILD_GOOS).$(BUILD_GOARCH)
cd $(RELEASE_ARTIFACTS_DIR) && shasum -a 256 certcal-$(VERSION).$(BUILD_GOOS).$(BUILD_GOARCH) >> $(CHECKSUM_FILE)
.PHONY: github-release
github-release:
gh release create $(VERSION) --title 'Release $(VERSION)' --notes-file docs/releases/$(VERSION).md $(RELEASE_ARTIFACTS_DIR)/*
# clean up tasks
.PHONY: clean
clean:
git clean -fdx