I use this Makefile from the Sphinx source directory to copy/commit to the GitHub Pages repo before pushing.
# Don't put trailing slash here: add it in rsync
# commands where necessary because its existence means
# something.
GHPAGES:=../
davedittrich.github.ioSHELL=/bin/bash
# Implement a date-based version numbering scheme.
SHORT_YEAR=$(shell date +%y)
# Strip leading spaces so math works right
MONTH=$(shell date +%m | sed 's/^0//')
DAY_OF_MONTH=$(shell date +%d|sed 's/^0//')
MINS_PAST_MIDNIGHT=$(shell expr `date +%H` \* 60 + `date +%M`)
MINUTE_IN_MONTH=$(shell echo $$(( ( $(DAY_OF_MONTH) - 1 ) * 24 * 60 + $(MINS_PAST_MIDNIGHT) )) )
DATE_VERSION=$(SHORT_YEAR).$(MONTH).$(MINUTE_IN_MONTH)
VERSION=$(shell cat VERSION)
.PHONY: _help
_help:
@echo VERSION=$(VERSION)
@echo DATE_VERSION=$(DATE_VERSION)
$(MAKE) help
.PHONY: bump
bump:
bumpversion --no-tag patch --current-version $(VERSION) --new-version $(DATE_VERSION)
.PHONY: publish
publish:
$(MAKE) gh-pages-commit
$(MAKE) gh-pages-push
.PHONY: push
push:
git push
source/robots.txt: robots.j2
env bash render_template robots.j2 source/robots.txt
.PHONY: gh-pages
gh-pages:
$(MAKE) -B source/robots.txt
$(MAKE) html
rsync -av \
--delete \
--exclude=README.md \
--exclude=.git \
--exclude=_downloads \
--exclude=.nohyde \
--exclude=.nojekyll \
-r \
build/html/ pgpkey.txt nwba redirect $(GHPAGES)
rsync -av \
downloads/ $(GHPAGES)/_downloads/
.PHONY: gh-pages-commit
gh-pages-commit: gh-pages
(cd $(GHPAGES) && git add _downloads/* && git commit -a -m 'Update gh-pages')
.PHONY: gh-pages-push
gh-pages-push:
(cd $(GHPAGES) && git push)
.PHONY: livehtml
livehtml:
sphinx-autobuild -p 0 \
--re-ignore '.*.swp' \
--re-ignore '.*.swx' \
-b html \
$(ALLSPHINXOPTS) \
$(BUILDDIR)/html