-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
31 lines (30 loc) · 929 Bytes
/
Makefile
File metadata and controls
31 lines (30 loc) · 929 Bytes
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
TAG ?=
VERSION := $(patsubst v%,%,$(TAG))
.PHONY: release
release:
@if [ -z "$(TAG)" ]; then \
echo "TAG is required (e.g. TAG=v0.0.3)"; \
exit 1; \
fi
@if [ -z "$(VERSION)" ]; then \
echo "Unable to derive version from TAG=$(TAG)"; \
exit 1; \
fi
@if ! git diff --quiet || ! git diff --cached --quiet; then \
echo "Working tree must be clean"; \
exit 1; \
fi
@if git rev-parse -q --verify "refs/tags/$(TAG)" >/dev/null; then \
echo "Tag $(TAG) already exists"; \
exit 1; \
fi
@if sed --version >/dev/null 2>&1; then \
sed -i "s/\"version\"[[:space:]]*:[[:space:]]*\"[^\"]*\"/\"version\": \"$(VERSION)\"/" package.json; \
else \
sed -i '' "s/\"version\"[[:space:]]*:[[:space:]]*\"[^\"]*\"/\"version\": \"$(VERSION)\"/" package.json; \
fi
@git add package.json
@git commit -s -m "release $(VERSION)"
@git tag -a "$(TAG)" -m "release $(VERSION)"
@git push origin HEAD
@git push origin "$(TAG)"