@@ -11,8 +11,9 @@ SHELL = /bin/bash
11
11
12
12
OUTPUT_DIR = $(CURDIR ) /.output
13
13
TEMPLATE = $(CURDIR )
14
+ VERSION := $(shell cat VERSION)
14
15
15
- # -----------------------------------
16
+ # PYTHON ENVIRON -----------------------------------
16
17
.PHONY : devenv
17
18
.venv :
18
19
@python3 --version
@@ -23,13 +24,9 @@ TEMPLATE = $(CURDIR)
23
24
wheel \
24
25
setuptools
25
26
26
- requirements.txt : requirements.in
27
- # freezes requirements
28
- .venv/bin/pip-compile --upgrade --build-isolation --output-file $@ $(word2, $^ )
29
-
30
27
devenv : .venv # # create a python virtual environment with tools to dev, run and tests cookie-cutter
31
28
# installing extra tools
32
- @$< /bin/pip3 install -r requirements.txt
29
+ @$< /bin/pip3 install -r requirements-dev .txt
33
30
# your dev environment contains
34
31
@$< /bin/pip3 list
35
32
@echo " To activate the virtual environment, run 'source $</bin/activate'"
@@ -46,7 +43,7 @@ tests: ## tests backed cookie
46
43
$(CURDIR ) /tests
47
44
48
45
49
- # -----------------------------------
46
+ # COOKIECUTTER -----------------------------------
50
47
.PHONY : play
51
48
52
49
$(OUTPUT_DIR ) :
@@ -71,41 +68,90 @@ endif
71
68
@echo "To see generated code, lauch 'code $(OUTPUT_DIR)'"
72
69
73
70
71
+ # VERSION BUMP -------------------------------------------------------------------------------
74
72
75
73
.PHONY : version-patch version-minor version-major
76
74
version-patch version-minor version-major : # # commits version as patch (bug fixes not affecting the API), minor/minor (backwards-compatible/INcompatible API addition or changes)
77
75
# upgrades as $(subst version-,,$@) version, commits and tags
78
76
@bump2version --verbose --list $(subst version-,,$@ )
79
77
80
78
81
- # -----------------------------------
82
- .PHONY : help
83
- # thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
84
- help : # # this colorful help
85
- @echo " Recipes for '$( notdir $( CURDIR) ) ':"
86
- @echo " "
87
- @awk --posix ' BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
88
- @echo " "
89
79
90
- git_clean_args = -dxf --exclude=.vscode/ --exclude=.venv/ --exclude=.python
80
+ # RELEASE -------------------------------------------------------------------------------
81
+
82
+ prod_prefix := v
83
+ _git_get_current_branch = $(shell git rev-parse --abbrev-ref HEAD)
84
+
85
+ # NOTE: be careful that GNU Make replaces newlines with space which is why this command cannot work using a Make function
86
+ _url_encoded_title = $(VERSION )
87
+ _url_encoded_tag = $(prod_prefix )$(VERSION )
88
+ _url_encoded_target = $(if $(git_sha ) ,$(git_sha ) ,master)
89
+ _prettify_logs = $$(git log \
90
+ $$(git describe --match="$(prod_prefix ) *" --abbrev=0 --tags ) ..$(if $(git_sha ) ,$(git_sha ) ,HEAD) \
91
+ --pretty=format:"- %s" )
92
+ define _url_encoded_logs
93
+ $(shell \
94
+ scripts/url-encoder.bash \
95
+ "$(_prettify_logs ) "\
96
+ )
97
+ endef
98
+ _git_get_repo_orga_name = $(shell git config --get remote.origin.url | \
99
+ grep --perl-regexp --only-matching "((?<=git@github\.com:) |(?<=https:\/\/github\.com\/))(.*?)(?=.git)")
100
+
101
+ .PHONY : .check-master-branch
102
+ .check-master-branch :
103
+ @if [ " $( _git_get_current_branch) " != " master" ]; then\
104
+ echo -e " \e[91mcurrent branch is not master branch." ; exit 1; \
105
+ fi
106
+
107
+ .PHONY : release
108
+ release pre-release : .check-master-branch # # Creates github release link. Usage: make release-prod git_sha=optional
109
+ # ensure tags are up-to-date
110
+ @git pull --tags
111
+ @echo -e " \e[33mOpen the following link to create a release:" ;
112
+ @echo -e " \e[32mhttps://github.com/$( _git_get_repo_orga_name) /releases/new?prerelease=$( if $( findstring pre-, $@ ) ,1,0) &target=$( _url_encoded_target) &tag=$( _url_encoded_tag) &title=$( _url_encoded_title) &body=$( _url_encoded_logs) " ;
113
+ @echo -e " \e[33mOr open the following link to create a release and paste the logs:" ;
114
+ @echo -e " \e[32mhttps://github.com/$( _git_get_repo_orga_name) /releases/new?prerelease=$( if $( findstring pre-, $@ ) ,1,0) &target=$( _url_encoded_target) &tag=$( _url_encoded_tag) &title=$( _url_encoded_title) " ;
115
+ @echo -e " \e[34m$( _prettify_logs) "
116
+
117
+
118
+ # TOOLS -----------------------------------
119
+
120
+ .PHONY : info
121
+ info : # # displays info about the scope
122
+ # python
123
+ @which python
124
+ @python --version
125
+ @which pip
126
+ @pip --version
127
+ @pip list
128
+ @cookiecutter --version
129
+ # environs
130
+ @echo " VERSION : $( VERSION) "
131
+ @echo " OUTPUT_DIR: $( OUTPUT_DIR) "
132
+ @echo " TEMPLATE: $( CURDIR) "
133
+ # cookiecutter config
134
+ @jq ' .' cookiecutter.json
91
135
92
136
.PHONY : clean clean-force
137
+
138
+ git_clean_args = -dx --force --exclude=.vscode/ --exclude=.venv/ --exclude=.python
139
+
93
140
clean : # # cleans all unversioned files in project and temp files create by this makefile
94
141
# Cleaning unversioned
95
142
@git clean -n $(git_clean_args )
96
143
@echo -n " Are you sure? [y/N] " && read ans && [ $$ {ans:-N} = y ]
97
144
@echo -n " $( shell whoami) , are you REALLY sure? [y/N] " && read ans && [ $$ {ans:-N} = y ]
98
145
@git clean $(git_clean_args )
99
- -rm -rf $(OUTPUT_DIR )
146
+ -rm -r --force $(OUTPUT_DIR )
100
147
101
148
clean-force : clean
102
149
# removing .venv
103
- -@rm -rf .venv
104
-
150
+ -@rm -r --force .venv
105
151
106
- .PHONY : info
107
- info : # # displays info about the scope
108
- # python
109
- @echo $( shell which python)
110
- @python --version
111
- @echo $( shell which pip)
152
+ .PHONY : help
153
+ help : # # this colorful help
154
+ @echo " Recipes for ' $( notdir $( CURDIR ) ) ': "
155
+ @echo " "
156
+ @awk --posix ' BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2} ' $( MAKEFILE_LIST )
157
+ @echo " "
0 commit comments