Skip to content

Commit 7044900

Browse files
committed
add publish makefile
1 parent 527fee4 commit 7044900

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

make/publish.mk

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# publish - build package and publish
2+
3+
# publish to pypi
4+
publish: release
5+
$(call require_pypi_config)
6+
@set -e;\
7+
if [ "$(version)" != "$(pypi_version)" ]; then \
8+
$(call verify_action,publish to PyPi) \
9+
echo publishing $(dist_name) $(version) to PyPI...;\
10+
flit publish;\
11+
else \
12+
echo $(dist_name) $(version) is up-to-date on PyPI;\
13+
fi
14+
15+
# check current pypi version
16+
pypi-check:
17+
$(call require_pypi_config)
18+
@echo '$(dist_name) local=$(version) pypi=$(call check_pypi_version)'
19+
20+
# clean up publish generated files
21+
publish-clean:
22+
rm -f .dist
23+
rm -rf .tox
24+
25+
# functions
26+
define require_pypi_config =
27+
$(if $(wildcard ~/.pypirc),,$(error publish failed; ~/.pypirc required))
28+
endef
29+
30+
pypi_version := $(shell pip install $(dist_name)==fnord.plough.plover.xyzzy 2>&1 |\
31+
awk -F'[,() ]' '/^ERROR: Could not find a version .* \(from versions:.*\)/{print $$(NF-1)}')
32+
33+
define check_null =
34+
$(if $(1),$(1),$(error $(2)))
35+
endef
36+
37+
check_pypi_version = $(call check_null,$(pypi_version),PyPi version query failed)

0 commit comments

Comments
 (0)