-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
45 lines (36 loc) · 1.43 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
VERSION := $(shell cat CHANGELOG.md | grep '^\#\#' | head -n1 | tr -d '\# ')
# Remove blank lines from beginning and end of file
# https://unix.stackexchange.com/a/552198
REMOVE_BLANK_LINES = awk 'NF {p=1} p' | tac | awk 'NF {p=1} p' | tac
# Shell command to strip text before first heading in changelog, then
# drop first line of file, then strip next heading and following text.
# Just copied from stackoverflow, if it stops working, then find
# another one.
RELEASE_NOTES = cat CHANGELOG.md | sed '/^\#\#/,$$!d' | tail -n+2 | sed -n '/^\#\#/q;p' | $(REMOVE_BLANK_LINES)
.PHONY: build
build:
go build ./cmd/sleepingd
# For the test commands, use DOCKER=0 to skip Docker invocation.
.PHONY: test-unit
test-unit:
./docker/run_in_docker.bash go test ./lib/sleepingd $(TEST_FLAGS)
.PHONY: test-integration
test-integration: build
./docker/run_in_docker.bash ./test/integration/run.bash $(TEST_FLAGS)
.PHONY: test
test: test-unit test-integration
.PHONY: version
version:
@echo "Current version is $(VERSION) according to CHANGELOG.md"
.PHONY: releasenotes
releasenotes: version
@printf '------------------------------\n'
@$(RELEASE_NOTES)
@printf '------------------------------\n'
.PHONY: release
release:
@echo "Releasing version $(VERSION)"
@$(RELEASE_NOTES) > .releasenotes.tmp.md
git tag v$(VERSION) HEAD $(if $(FORCE),-f,)
git push origin v$(VERSION) $(if $(FORCE),-f,)
goreleaser release --rm-dist --release-notes=.releasenotes.tmp.md