
#VERSION = $(shell python3 setup.py --version)
VERSION = $(shell sed -n -e '/^package_version/s/.* = "\(.*\)"/\1/p' skytools/installer_config.py)
RXVERSION = $(shell echo "$(VERSION)" | sed 's/\./[.]/g')
TAG = v$(VERSION)
NEWS = NEWS.rst

all:
	tox -e lint
	tox -e py3

clean:
	rm -rf build *.egg-info */__pycache__ tests/*.pyc
	rm -rf .pybuild MANIFEST

sdist:
	python3 setup.py sdist

lint:
	tox -e lint

xlint:
	tox -e xlint

xclean: clean
	rm -rf .tox dist

checkver:
	@echo "Checking version"
	@grep -q '^Skytools $(RXVERSION)\b' $(NEWS) \
	|| { echo "Version '$(VERSION)' not in $(NEWS)"; exit 1; }
	@echo "Checking git repo"
	@git diff --stat --exit-code || { echo "ERROR: Unclean repo"; exit 1; }

release: checkver
	git tag $(TAG)
	git push github $(TAG):$(TAG)

unrelease:
	git push github :$(TAG)
	git tag -d $(TAG)

shownote:
	gawk -v VER="$(VERSION)" -f etc/note.awk $(NEWS) \
	| pandoc -f rst -t gfm --wrap=none

showuses:
	grep uses: .github/workflows/*.yml

test-setup:
	@set -e; \
	for py in py310 py312 py314; do \
	  for st in 77 78 79 80 81 82; do \
	    env="$${py}-setuptools$${st}"; \
	    echo "##### $${env} #####"; \
	    tox -e $${py}-setuptools$${st}; \
	  done; \
	done
