-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
103 lines (78 loc) · 2.49 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
PACKAGE_NAME = jupyter-nbrequirements
PACKAGE_DESCRIPTION = Dependency manager for Jupyter Notebooks
# path to the python package
PACKAGE = jupyter_nbrequirements
CURRENT_DIR ?= $(shell pwd)
OUTPUT_DIR ?= ./
define get_branch
$(shell git branch | sed -n '/\* /s///p')
endef
define get_tag
$(shell \
if [ -z "`git status --porcelain`" ]; then \
git describe \
--exact-match \
--tags HEAD 2>/dev/null || (>&2 echo "Tag has not been created.") \
fi \
)
endef
define get_tree_state
$(shell \
if [ -z "`git status --porcelain`" ]; then \
echo "clean" \
else \
echo "dirty" \
fi
)
endef
GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_BRANCH = $(call get_branch)
GIT_TAG = $(call get_tag)
GIT_TREE_STATE = $(call get_tree_state)
ifeq (${GIT_TAG},)
GIT_TAG = $(shell git rev-parse --abbrev-ref HEAD)
endif
VERSION ?= $(shell v=$(GIT_BRANCH); echo $${v/release-/})
PYPI_REPOSITORY ?= https://upload.pypi.org/legacy/
.PHONY: build
build:
cd js/ >/dev/null ; \
npm install && npm run build
.PHONY: build-prod
build-prod:
cd js/ >/dev/null ; \
npm install && npm run build-prod
.PHONY: patch
patch: SHELL:=/bin/bash
patch: build-prod validate
- rm -rf build/ dist/
- git tag --delete "v${VERSION}"
$(MAKE) changelog
sed -i "s/__version__ = \(.*\)/__version__ = \"${VERSION}\"/g" ${PACKAGE}/__about__.py
sed -i "s/\"version\": \"\(.*\)\"/\"version\": \"${VERSION}\"/g" js/package.json
python setup.py sdist bdist_wheel
twine check dist/* || (echo "Twine check did not pass. Aborting."; exit 1)
git commit -a -m ":wrench: Patch ${VERSION}" --signoff
git tag -a "v${VERSION}" -m "Patch ${VERSION}"
.PHONY: release
release: SHELL:=/bin/bash
release: build-prod validate
- rm -rf build/ dist/
- git tag --delete "v${VERSION}"
$(MAKE) changelog
sed -i "s/__version__ = \(.*\)/__version__ = \"${VERSION}\"/g" ${PACKAGE}/__about__.py
sed -i "s/\"version\": \"\(.*\)\"/\"version\": \"${VERSION}\"/g" js/package.json
python setup.py sdist bdist_wheel
twine check dist/* || (echo "Twine check did not pass. Aborting."; exit 1)
git commit -a -m ":tada: Release ${VERSION}" --allow-empty --signoff
git tag -a "v${VERSION}" -m "Release ${VERSION}"
validate:
@echo "Validating version '${VERSION}' on branch '${GIT_BRANCH}'"
if [ "$(shell python -c \
"from semantic_version import validate; print( validate('${VERSION}') )" \
)" != "True" ]; then \
echo "Invalid version. Aborting."; \
exit 1; \
fi
changelog:
RELEASE_VERSION=${VERSION} gitchangelog > CHANGELOG.rst