-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
66 lines (56 loc) · 1.95 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
# (c) Oleksii Tsvietnov, [email protected]
#
# Variables:
ECHO_BIN ?= echo
CP_BIN ?= cp
SED_BIN ?= sed
PWD_BIN ?= pwd
BASENAME_BIN ?= basename
GIT_BIN ?= git
SHA256SUM_BIN ?= sha256sum
# -------------------------------------------------------------------------
# Set a default target
.MAIN: usage
DIR = $(shell ${PWD_BIN} -P)
SELF = $(shell ${BASENAME_BIN} ${DIR})
VER = $(shell ${SED_BIN} -n '1s/^[[:space:]]*//; 1s/[[:space:]]*$$//; 1p' ${DIR}/version)
VERSION ?= ${VER}
LAST_COMMIT = $(shell ${GIT_BIN} log -1 | sed -n '/^commit/s/^commit //p')
usage:
@${ECHO_BIN} "Usage: make [target] ..."
@${ECHO_BIN} ""
@${ECHO_BIN} "Examples: make setver"
@${ECHO_BIN} " make VERSION=v1.15.2 setver"
@${ECHO_BIN} " make settag"
@${ECHO_BIN} " make push"
@${ECHO_BIN} " make release"
@${ECHO_BIN} " make VERSION=v1.1.14 release"
@${ECHO_BIN} ""
@${ECHO_BIN} "Description:"
@${ECHO_BIN} " setver Set a new version (is taken from environment or file)."
@${ECHO_BIN} " settag Set a new version as a tag to the last commit."
@${ECHO_BIN} " push Push to the repo (with tags)."
@${ECHO_BIN} " release Set a version, tag and push to the repo."
@${ECHO_BIN} " test Run all tests"
@${ECHO_BIN} ""
test:
@(cd tests && roundup)
setver:
@${ECHO_BIN} "Setting version to ${VERSION}"
@${SED_BIN} -i "s/trc_version=\".*$$/trc_version=\"${VERSION}\"/" ${DIR}/trc
@${SED_BIN} -i "1s/.*/${VERSION}/" ${DIR}/version
settag:
@${ECHO_BIN} "Setting ${VERSION} as a tag to ${LAST_COMMIT}"
@${GIT_BIN} tag ${VERSION} ${LAST_COMMIT} 2>/dev/null || true
push:
@${ECHO_BIN} "Pushing commits..."
@${GIT_BIN} push origin
@${ECHO_BIN} "Pushing tags..."
@${GIT_BIN} push origin ${VERSION}
publish:
@${CP_BIN} -f trc docs/
@(cd docs && ${SHA256SUM_BIN} trc > trc.sha256)
cirelease: test setver settag publish
@${GIT_BIN} add .
@${GIT_BIN} ci -m "Release new version: ${VERSION}"
release: cirelease push