Skip to content

Commit

Permalink
Update release.mk to 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Nov 8, 2018
1 parent 4a9ef1b commit 79e3941
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions release.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Makefile.rules version 1.0 (2017-12-19)
# release.mk version 1.3 (2018-11-03)
#
# Helpful Makefile rules for releasing Python packages.
# https://github.com/mgedmin/python-project-skel

# You might want to change these
FILE_WITH_VERSION ?= setup.py
Expand All @@ -10,15 +11,19 @@ CHANGELOG_FORMAT ?= $(changelog_ver) ($(changelog_date))

# These should be fine
PYTHON ?= python
PYPI_PUBLISH ?= rm -rf dist && $(PYTHON) setup.py -q sdist bdist_wheel && twine upload dist/* && $(VCS_TAG) `$(PYTHON) setup.py --version`
PYPI_PUBLISH ?= rm -rf dist && $(PYTHON) setup.py -q sdist bdist_wheel && twine check dist/* && twine upload dist/*
LATEST_RELEASE_MK_URL = https://raw.githubusercontent.com/mgedmin/python-project-skel/master/release.mk

# These should be fine, as long as you use Git
VCS_GET_LATEST ?= git pull
VCS_STATUS ?= git status --porcelain
VCS_EXPORT ?= git archive --format=tar --prefix=tmp/tree/ HEAD | tar -xf -
VCS_TAG ?= git tag -s
VCS_TAG ?= git tag -s $(changelog_ver) -m \"Release $(changelog_ver)\"
VCS_COMMIT_AND_PUSH ?= git commit -av -m "Post-release version bump" && git push && git push --tags

# These are internal implementation details
changelog_ver = `$(PYTHON) setup.py --version`
changelog_date = `LC_ALL=C date +'$(CHANGELOG_DATE_FORMAT)'`


.PHONY: dist
Expand Down Expand Up @@ -50,7 +55,7 @@ distcheck-sdist:
$(VCS_EXPORT) && \
cd tmp && \
tar -xzf ../dist/$$pkg_and_version.tar.gz && \
diff -ur $$pkg_and_version tree -x PKG-INFO -x setup.cfg -x '*.egg-info' && \
diff -ur $$pkg_and_version tree -x PKG-INFO -x setup.cfg -x '*.egg-info' -I'^#' && \
cd $$pkg_and_version && \
make dist check && \
cd .. && \
Expand All @@ -60,13 +65,16 @@ distcheck-sdist:
cd ../two/ && \
tar -xzf ../$$pkg_and_version/dist/$$pkg_and_version.tar.gz && \
cd .. && \
diff -ur one two -x SOURCES.txt && \
diff -ur one two -x SOURCES.txt -I'^#:' && \
cd .. && \
rm -rf tmp && \
echo "sdist seems to be ok"

# NB: do not use $(MAKE) because then make -n releasechecklist will
# actually run the distcheck instead of just printing what it does
.PHONY: check-latest-rules
check-latest-rules:
ifndef FORCE
@curl -s $(LATEST_RELEASE_MK_URL) | cmp -s release.mk || { printf "\nYour release.mk does not match the latest version at\n$(LATEST_RELEASE_MK_URL)\n\n" 1>&2; exit 1; }
endif

.PHONY: check-latest-version
check-latest-version:
Expand All @@ -81,17 +89,17 @@ check-version-number:
check-long-description:
@$(PYTHON) setup.py --long-description | rst2html --exit-status=2 > /dev/null

changelog_ver = `$(PYTHON) setup.py --version`
changelog_date = `LC_ALL=C date +'$(CHANGELOG_DATE_FORMAT)'`

.PHONY: check-changelog
check-changelog:
@ver_and_date="$(CHANGELOG_FORMAT)" && \
grep -q "^$$ver_and_date$$" $(FILE_WITH_CHANGELOG) || { \
echo "$(FILE_WITH_CHANGELOG) has no entry for $$ver_and_date"; exit 1; }

# NB: do not use $(MAKE) because then make -n releasechecklist will
# actually run the distcheck instead of just printing what it does

.PHONY: releasechecklist
releasechecklist: check-latest-version check-version-number check-long-description check-changelog
releasechecklist: check-latest-rules check-latest-version check-version-number check-long-description check-changelog
make distcheck

.PHONY: release
Expand All @@ -106,6 +114,7 @@ define release_recipe =
@echo "Please run"
@echo
@echo " $(PYPI_PUBLISH)"
@echo " $(VCS_TAG)"
@echo
@echo "Please increment the version number in $(FILE_WITH_VERSION)"
@echo "and add a new empty entry at the top of the changelog in $(FILE_WITH_CHANGELOG), then"
Expand Down

0 comments on commit 79e3941

Please sign in to comment.