-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (68 loc) · 2.5 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
help:
@echo "\nAvailable commnads:"
@echo ">> init : Initiates python environment" | sed 's/^/ /'
@echo ">> clean : removes all pycaches" | sed 's/^/ /'
@echo ">> commit : commits all changes to git" | sed 's/^/ /'
@echo ">> release : Updates version, builds and releases package to Pypy" | sed 's/^/ /'
init:
@pip install pip-chill
@pip install --upgrade twine
clean:
@find . -name \*.pyc -delete
@find . -type d -name "__pycache__" -delete
commit:
@git add -A
@DESCRIPTION=$$(gum write --width 60 --height 6 --base.margin "1 1" --cursor.foreground 31 --placeholder "Details of this change (CTRL+D to finish)");\
gum confirm --selected.background 31 "Commit changes?" && git commit -m "$$DESCRIPTION"
@git push origin master
changelog:
@TAG=`git describe --abbrev=0 --tags 2>/dev/null`; \
if [ -z "$$TAG" ]; then \
TAG=`git rev-list --max-parents=0 HEAD`; \
fi; \
COMMITS=`git log --oneline $$TAG..HEAD | grep -v -e "Typo" -e "Typos" -e "Bugfix"`; \
if [ -z "$$COMMITS" ]; then \
echo "No new commits since the last tag."; \
exit 0; \
fi; \
echo "## Changes since $$TAG" >> CHANGELOG.md; \
echo "" >> CHANGELOG.md; \
while read -r COMMIT; do \
SHA=`echo $$COMMIT | awk '{print $$1}'`; \
DESCRIPTION=`echo $$COMMIT | sed 's/^[^ ]* //'`; \
echo "* $$SHA: $$DESCRIPTION" >> CHANGELOG.md; \
done <<< "$$COMMITS"
release:
@UPDATE=$$(gum choose "Major" "Minor" "Patch" --limit "1" --cursor.margin "0 1" --cursor.foreground "");\
VERSION=$(shell grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3);\
IFS=. read major minor patch <<<"$$VERSION";\
if [ "$$UPDATE" = "Major" ]; then\
major=$$(( $$major + 1 ));\
minor=0;\
patch=0;\
fi;\
if [ "$$UPDATE" = "Minor" ]; then\
minor=$$(( $$minor + 1 ));\
patch=0;\
fi;\
if [ "$$UPDATE" = "Patch" ]; then\
patch=$$(($$patch + 1));\
fi;\
NEW="$$major.$$minor.$$patch";\
sed -i "" "s/^version = ".*"/version = \"$$NEW\"/" pyproject.toml;\
git add pyproject.toml;\
git commit -m "Updated version";\
python -m build;\
$(MAKE) changelog;\
git tag -a $$NEW -m "Release";\
git push origin master --tags;\
gh release create $$NEW -F CHANGELOG.md --title "Tinydocs v$$NEW";\
twine upload dist/*;\
rm CHANGELOG.md
retag:
@TAG=$$(gum input --placeholder "version to drop");\
gum confirm --selected.background 31 "Are you sure?" && git tag -d $$TAG && git push --delete origin $$TAG;\
git add -A;\
git commit -m "Bugfix";\
git tag -a $$TAG -m "Pre-Release";\
git push origin master --tags