erynwells.me/Makefile

46 lines
1.4 KiB
Makefile

# Eryn Wells <eryn@erynwells.me>
CONTENT_PATH=content
DEPLOY_USER=eryn
DEPLOY_HOSTNAME=nutmeg.erynwells.me
DEPLOY_PATH=/srv/www/erynwells.me/html
DEPLOY_LOCATION=$(DEPLOY_USER)@$(DEPLOY_HOSTNAME):$(DEPLOY_PATH)
HOSTNAME=$(shell hostname -s)
NETHACK_LOGFILE=$(shell command nethack --showpaths | grep scoredir | sed 's/.*"\(.*\)".*/\1/g')/logfile
NETHACK_LOGFILE_DATA_FILE=data/nethack/logfile/$(HOSTNAME).json
.PHONY: site deploy clean
site: nethack
@echo "Building site"
hugo
deploy: site
@echo "Deploying to $(DEPLOY_LOCATION)"
rsync -avz --no-times --no-perms --delete public/ $(DEPLOY_LOCATION)
git tag -f deploy-$(shell date +%Y-%m-%d)
nethack: nethack-logfile nethack-commit
nethack-logfile: $(NETHACK_LOGFILE)
ifeq (,$(wildcard $<))
@echo "Importing Nethack logfile from $(NETHACK_LOGFILE)"
scripts/import-nethack-logfile.py -o $(NETHACK_LOGFILE_DATA_FILE) $<
endif
nethack-commit: $(NETHACK_LOGFILE_DATA_FILE)
if ! git diff --quiet $<; then git commit -m "Update Nethack logfile for $(HOSTNAME)" -- $<; fi
weeknotes: YEAR=$(shell date '+%Y')
weeknotes: WEEK_NUMBER=$(shell date '+%V')
weeknotes: UPCOMING_SUNDAY=$(shell scripts/weeknotes show --date)
weeknotes: PAGE_PATH=$(shell scripts/weeknotes show)
weeknotes: $(PAGE_PATH)
hugo new -k weeknotes --clock "$(UPCOMING_SUNDAY)" -c "$(CONTENT_PATH)" "$(PAGE_PATH)"
sed -I -e "s/%%WEEK_NUMBER%%/$(WEEK_NUMBER)/" "$(PAGE_PATH)"
clean:
rm -rf public/