@@ -126,10 +126,10 @@ build:
126126 python setup.py sdist bdist_wheel
127127
128128
129- .PHONY : release
130- release : build # release by-hand (TEMP SOLUTION until FIXME: https://github.com/ITISFoundation/osparc-simcore-python-client/issues/16)
131- python -m pip install twine
132- python -m twine upload dist/*
129+ # .PHONY: release
130+ # release: build # release by-hand (TEMP SOLUTION until FIXME: https://github.com/ITISFoundation/osparc-simcore-python-client/issues/16)
131+ # python -m pip install twine
132+ # python -m twine upload dist/*
133133
134134
135135# # DOCKER -------------------------------------------------------------------------------
@@ -141,4 +141,51 @@ image:
141141
142142.PHONY : shell
143143shell :
144- docker run -it $(APP_NAME ) :latest /bin/bash
144+ docker run -it $(APP_NAME ) :latest /bin/bash
145+
146+
147+
148+ # RELEASE --------------------------------------------------------------------------------------------------------------------------------------------
149+
150+ staging_prefix := staging_
151+ prod_prefix := v
152+ _git_get_current_branch = $(shell git rev-parse --abbrev-ref HEAD)
153+
154+ # NOTE: be careful that GNU Make replaces newlines with space which is why this command cannot work using a Make function
155+ _url_encoded_title = $(if $(findstring -staging, $@ ) ,Staging% 20$(name ) ,)$(version )
156+ _url_encoded_tag = $(if $(findstring -staging, $@ ) ,$(staging_prefix )$(name ) ,$(prod_prefix ) )$(version )
157+ _url_encoded_target = $(if $(git_sha ) ,$(git_sha ) ,$(if $(findstring -hotfix, $@ ) ,$(_git_get_current_branch ) ,master) )
158+ _prettify_logs = $$(git log \
159+ $$(git describe --match="$(if $(findstring -staging, $@ ) ,$(staging_prefix ) ,$(prod_prefix ) ) *" --abbrev=0 --tags ) ..$(if $(git_sha ) ,$(git_sha ) ,HEAD) \
160+ --pretty=format:"- %s" )
161+ define _url_encoded_logs
162+ $(shell \
163+ scripts/url-encoder.bash \
164+ "$(_prettify_logs ) "\
165+ )
166+ endef
167+ _git_get_repo_orga_name = $(shell git config --get remote.origin.url | \
168+ grep --perl-regexp --only-matching "((?<=git@github\.com:) |(?<=https:\/\/github\.com\/))(.*?)(?=.git)")
169+
170+ .PHONY : .check-master-branch
171+ .check-master-branch :
172+ @if [ " $( _git_get_current_branch) " != " master" ]; then\
173+ echo -e " \e[91mcurrent branch is not master branch." ; exit 1; \
174+ fi
175+
176+ .PHONY : release-staging release-prod
177+ release-staging release-prod : .check-master-branch # # Helper to create a staging or production release in Github (usage: make release-staging name=sprint version=1 git_sha=optional or make release-prod version=1.2.3 git_sha=optional)
178+ # ensure tags are up-to-date
179+ @git pull --tags
180+ @echo -e " \e[33mOpen the following link to create the $( if $( findstring -staging, $@ ) ,staging,production) release:" ;
181+ @echo -e " \e[32mhttps://github.com/$( _git_get_repo_orga_name) /releases/new?prerelease=$( if $( findstring -staging, $@ ) ,1,0) &target=$( _url_encoded_target) &tag=$( _url_encoded_tag) &title=$( _url_encoded_title) &body=$( _url_encoded_logs) " ;
182+ @echo -e " \e[33mOr open the following link to create the $( if $( findstring -staging, $@ ) ,staging,production) release and paste the logs:" ;
183+ @echo -e " \e[32mhttps://github.com/$( _git_get_repo_orga_name) /releases/new?prerelease=$( if $( findstring -staging, $@ ) ,1,0) &target=$( _url_encoded_target) &tag=$( _url_encoded_tag) &title=$( _url_encoded_title) " ;
184+ @echo -e " \e[34m$( _prettify_logs) "
185+
186+ .PHONY : release-hotfix
187+ release-hotfix : # # Helper to create a hotfix release in Github (usage: make release-hotfix version=1.2.4 git_sha=optional)
188+ # ensure tags are up-to-date
189+ @git pull --tags
190+ @echo -e " \e[33mOpen the following link to create the $( if $( findstring -staging, $@ ) ,staging,production) release:" ;
191+ @echo -e " \e[32mhttps://github.com/$( _git_get_repo_orga_name) /releases/new?prerelease=$( if $( findstring -staging, $@ ) ,1,0) &target=$( _url_encoded_target) &tag=$( _url_encoded_tag) &title=$( _url_encoded_title) &body=$( _url_encoded_logs) " ;
0 commit comments