BUILDDIR?=../ungleich-staticcms-build
DESTINATION=ungleichstatic@staticweb.ungleich.ch:/home/services/www/ungleichstatic/staticcms.ungleich.ch/www/u/

all: goodpush

pull:
	git pull

push:
	git push

goodpush:
	make publish && make push

publish: pull build deploy

deploy: permissions
	rsync -av --delete --exclude .lektor/ $(BUILDDIR)/u/ $(DESTINATION)
	rsync -av --delete $(BUILDDIR)/sitemap.xml $(DESTINATION)

permissions: build
	find $(BUILDDIR) -type f -exec chmod 0644 {} \;
	find $(BUILDDIR) -type d -exec chmod 0755 {} \;

build: venv
	. ./venv/bin/activate && lektor build -O $(BUILDDIR)

clean:
	rm -rf $(BUILDDIR)

venv: requirements.txt
	python3 -m venv venv
	sh -c ". ./venv/bin/activate && pip install -r requirements.txt"
