2017-08-22 02:02:39 +02:00
|
|
|
SHELL=/bin/bash -eo pipefail
|
|
|
|
|
2022-04-10 23:50:12 +02:00
|
|
|
release-major:
|
2019-05-01 17:20:50 +02:00
|
|
|
$(eval export TAG=$(shell git describe --tags --match 'v*.*.*' | perl -ne '/^v(\d+)\.(\d+)\.(\d+)/; print "v@{[$$1+1]}.0.0"'))
|
2017-08-22 02:02:39 +02:00
|
|
|
$(MAKE) release
|
|
|
|
|
2022-04-10 23:50:12 +02:00
|
|
|
release-minor:
|
2019-05-01 17:20:50 +02:00
|
|
|
$(eval export TAG=$(shell git describe --tags --match 'v*.*.*' | perl -ne '/^v(\d+)\.(\d+)\.(\d+)/; print "v$$1.@{[$$2+1]}.0"'))
|
2017-08-22 02:02:39 +02:00
|
|
|
$(MAKE) release
|
|
|
|
|
2022-04-10 23:50:12 +02:00
|
|
|
release-patch:
|
2019-05-01 17:20:50 +02:00
|
|
|
$(eval export TAG=$(shell git describe --tags --match 'v*.*.*' | perl -ne '/^v(\d+)\.(\d+)\.(\d+)/; print "v$$1.$$2.@{[$$3+1]}"'))
|
2017-08-22 02:02:39 +02:00
|
|
|
$(MAKE) release
|
|
|
|
|
|
|
|
release:
|
2022-04-10 23:50:12 +02:00
|
|
|
@if ! git diff --cached --exit-code; then echo "Commit staged files before proceeding"; exit 1; fi
|
|
|
|
@if [[ -z $$TAG ]]; then echo "Use release-{major,minor,patch}"; exit 1; fi
|
|
|
|
@if ! type -P pandoc; then echo "Please install pandoc"; exit 1; fi
|
|
|
|
@if ! type -P sponge; then echo "Please install moreutils"; exit 1; fi
|
|
|
|
@if ! type -P http; then echo "Please install httpie"; exit 1; fi
|
|
|
|
@if ! type -P twine; then echo "Please install twine"; exit 1; fi
|
|
|
|
$(eval REMOTE=$(shell git remote get-url origin | perl -ne '/([^\/\:]+\/[^\/\:]+?)(\.git)?$$/; print $$1'))
|
2017-08-22 02:02:39 +02:00
|
|
|
$(eval GIT_USER=$(shell git config --get user.email))
|
|
|
|
$(eval GH_AUTH=$(shell if grep -q '@github.com' ~/.git-credentials; then echo $$(grep '@github.com' ~/.git-credentials | python3 -c 'import sys, urllib.parse as p; print(p.urlparse(sys.stdin.read()).netloc.split("@")[0])'); else echo $(GIT_USER); fi))
|
|
|
|
$(eval RELEASES_API=https://api.github.com/repos/${REMOTE}/releases)
|
|
|
|
$(eval UPLOADS_API=https://uploads.github.com/repos/${REMOTE}/releases)
|
|
|
|
git pull
|
|
|
|
git clean -x --force $$(python setup.py --name)
|
|
|
|
TAG_MSG=$$(mktemp); \
|
|
|
|
echo "# Changes for ${TAG} ($$(date +%Y-%m-%d))" > $$TAG_MSG; \
|
|
|
|
git log --pretty=format:%s $$(git describe --abbrev=0)..HEAD >> $$TAG_MSG; \
|
|
|
|
$${EDITOR:-emacs} $$TAG_MSG; \
|
|
|
|
if [[ -f Changes.md ]]; then cat $$TAG_MSG <(echo) Changes.md | sponge Changes.md; git add Changes.md; fi; \
|
|
|
|
if [[ -f Changes.rst ]]; then cat <(pandoc --from markdown --to rst $$TAG_MSG) <(echo) Changes.rst | sponge Changes.rst; git add Changes.rst; fi; \
|
|
|
|
git commit -m ${TAG}; \
|
|
|
|
git tag --sign --annotate --file $$TAG_MSG ${TAG}
|
|
|
|
git push --follow-tags
|
2022-04-10 23:50:12 +02:00
|
|
|
http --check-status --auth ${GH_AUTH} ${RELEASES_API} tag_name=${TAG} name=${TAG} \
|
2017-08-22 02:02:39 +02:00
|
|
|
body="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')"
|
|
|
|
$(MAKE) install
|
2022-04-10 23:50:12 +02:00
|
|
|
http --check-status --auth ${GH_AUTH} POST ${UPLOADS_API}/$$(http --auth ${GH_AUTH} ${RELEASES_API}/latest | jq .id)/assets \
|
2017-08-22 02:02:39 +02:00
|
|
|
name==$$(basename dist/*.whl) label=="Python Wheel" < dist/*.whl
|
2022-04-10 23:50:12 +02:00
|
|
|
$(MAKE) release-pypi
|
2022-04-11 00:05:55 +02:00
|
|
|
$(MAKE) release-docs
|
|
|
|
|
|
|
|
release-docs:
|
|
|
|
$(MAKE) docs
|
|
|
|
-git branch -D gh-pages
|
|
|
|
git checkout -B gh-pages-stage
|
|
|
|
touch docs/html/.nojekyll
|
|
|
|
git add --force docs/html
|
|
|
|
git commit -m "Docs for ${TAG}"
|
|
|
|
git push --force origin $$(git subtree split --prefix docs/html --branch gh-pages):refs/heads/gh-pages
|
|
|
|
git checkout -
|
2017-08-22 02:02:39 +02:00
|
|
|
|
2022-04-10 23:50:12 +02:00
|
|
|
release-pypi:
|
|
|
|
python -m build
|
2020-08-29 22:15:52 +02:00
|
|
|
twine upload dist/*.tar.gz dist/*.whl --sign --verbose
|
2017-08-22 02:02:39 +02:00
|
|
|
|
|
|
|
.PHONY: release
|