From 2baa832c66ce5ef657b331daec03cf2414dbe3ad Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Sat, 4 Mar 2023 16:38:19 -0800 Subject: [PATCH] Use gh to manage releases --- common.mk | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/common.mk b/common.mk index 899ac8c..cd84879 100644 --- a/common.mk +++ b/common.mk @@ -17,13 +17,8 @@ release: @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 gh; then echo "Please install gh"; 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')) - $(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); \ @@ -35,14 +30,15 @@ release: git commit -m ${TAG}; \ git tag --sign --annotate --file $$TAG_MSG ${TAG} git push --follow-tags - http --check-status --auth ${GH_AUTH} ${RELEASES_API} tag_name=${TAG} name=${TAG} \ - body="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')" $(MAKE) install - http --check-status --auth ${GH_AUTH} POST ${UPLOADS_API}/$$(http --auth ${GH_AUTH} ${RELEASES_API}/latest | jq .id)/assets \ - name==$$(basename dist/*.whl) label=="Python Wheel" < dist/*.whl + gh release create ${TAG} dist/*.whl --notes="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')" $(MAKE) release-pypi $(MAKE) release-docs +release-pypi: + python -m build + twine upload dist/*.tar.gz dist/*.whl --sign --verbose + release-docs: $(MAKE) docs -git branch -D gh-pages @@ -53,8 +49,4 @@ release-docs: git push --force origin $$(git subtree split --prefix docs/html --branch gh-pages):refs/heads/gh-pages git checkout - -release-pypi: - python -m build - twine upload dist/*.tar.gz dist/*.whl --sign --verbose - .PHONY: release