-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (52 loc) · 1.51 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
.POSIX:
.SUFFIXES:
LINT=shellcheck
TEST=./unittest
# MAIN TARGETS
all: test check
clean:
@echo '# Delete distributed files: rm -rf ./dist' >&2
@rm -rf ./dist
info:
@printf '# OS info: '
@uname -rsv;
@printf '# Development dependencies:\n'
@echo; $(LINT) -V
@echo; $(TEST) -v
check: $(LINT)
@printf '# Static analysis: $(LINT) unittest tests/*.sh\n' >&2
@$(LINT) unittest tests/*.sh
test:
@echo '# Unit tests: $(TEST)' >&2
@$(TEST)
install:
@echo '# Install in /usr/local/bin' >&2
@mkdir -p /usr/local/bin
@cp unittest /usr/local/bin/
dist: unittest
@echo '# Create release artifacts in ./dist' >&2
@mkdir -p ./dist
@cp unittest ./dist/unittest
@echo '# Create checksum' >&2
@cd ./dist; sha256sum unittest >./unittest.sha256sum
release:
@echo '# Update local branch' >&2
@git pull --rebase
@echo '# Create new release tag' >&2
@PREV_VER_TAG=$$(git tag | grep "^v" | sed 's/^v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1); \
CURRENT_VER=$$(./unittest -v 2>&1 | cut -d' ' -f2); \
if [ "$$PREV_VER_TAG" = "$$CURRENT_VER" ]; then \
echo "ERROR: unittest is in the same version as previous release ($$PREV_VER_TAG). Aborting"; \
exit 1; \
fi; \
printf 'Choose new version number (calver) for release [%s]: ' "$${CURRENT_VER:=23.11}"; \
read -r VERSION; \
if [ -z "$$VERSION" ]; then \
VERSION="$$CURRENT_VER"; \
fi; \
git tag "v$$VERSION"; \
git push --tags
# HELPERS
$(LINT):
@printf '# $@ installation path: ' >&2
@command -v $@ >&2 || { echo 'ERROR: Cannot find $@' >&2; exit 1; }