forked from ungleich-public/cdist-web
79 lines
3.3 KiB
Makefile
79 lines
3.3 KiB
Makefile
WEBSITE_SRC_DIR=src
|
|
WEBSITE_MAN_PAGE="$(WEBSITE_SRC_DIR)/cdist-manual.rst"
|
|
WEBSITE_HTML_DIST_DIR=dist/html
|
|
WEBSITE_ARCHIVE=cdist-www.tar.gz
|
|
WEBSITE_REMOTE_HOST=staticweb.ungleich.ch
|
|
WEBSITE_REMOTE_DIR=/home/services/www/nico/www.cdi.st/www/
|
|
WEBSITE_MANUALS_DIR="$(WEBSITE_SRC_DIR)/extra/manual"
|
|
|
|
CDIST_DIR=../cdist
|
|
CDIST_DOCS_DIR="$(CDIST_DIR)/docs"
|
|
CDIST_HELPER="$(CDIST_DIR)/bin/cdist-build-helper"
|
|
CDIST_CHANGELOG_VERSION=$(shell $(CDIST_HELPER) changelog-version)
|
|
CDIST_CHANGELOG_FILE="$(CDIST_DOCS_DIR)/changelog"
|
|
CDIST_DOCS_HTML_DIST_DIR="$(CDIST_DOCS_DIR)/dist/html"
|
|
CDIST_MAKE_VERSION=make -C "$(CDIST_DIR)" version
|
|
CDIST_MAKE_HTML=make -C "$(CDIST_DIR)" html
|
|
CDIST_CLEAN_HTML=make -C "$(CDIST_DOCS_DIR)/src" clean
|
|
|
|
SPHINXH=make -C $(WEBSITE_SRC_DIR) html
|
|
SPHINXC=make -C $(WEBSITE_SRC_DIR) clean
|
|
|
|
.PHONY: help
|
|
help:
|
|
@echo "Please use \`make <target>' where <target> is one of"
|
|
@echo " build only build static web"
|
|
@echo " publish only publish built web"
|
|
@echo " release update web with latest cdist release and build static web"
|
|
@echo " release-publish do release and then publish"
|
|
@echo " release-no-latest update web without latest cdist release and build static web"
|
|
@echo " release-publish-no-latest do release-no-latest and then publish"
|
|
@echo " clean clean generated files"
|
|
|
|
|
|
################################################################################
|
|
# Website
|
|
#
|
|
|
|
# Make cdist html manual.
|
|
# Generate rst changelog.
|
|
# Create target version manual directory.
|
|
# Copy target version manual directory to website.
|
|
# Add latest manual page.
|
|
# Update latest manual link.
|
|
release-prepare:
|
|
$(CDIST_MAKE_VERSION)
|
|
$(CDIST_MAKE_HTML)
|
|
@awk '/^[0-9a-z.]+: [0-9-]+$$/ { print; for(i = 0; i < length; ++i) { printf "~"; }; printf "\n"; next; } { print; }' "$(CDIST_CHANGELOG_FILE)" > "$(WEBSITE_SRC_DIR)/cdist-changelog.rst"
|
|
@mkdir -p "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/"
|
|
@rsync -a "$(CDIST_DOCS_HTML_DIST_DIR)/" "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/"
|
|
|
|
release-prepare-latest: release-prepare
|
|
@grep '$(CDIST_CHANGELOG_VERSION)' "$(WEBSITE_MAN_PAGE)" || awk 'BEGIN { print_new = 0; } /All versions/ { print; print_new = 1; next; } print_new == 1 { print; print "* `$(CDIST_CHANGELOG_VERSION) <manual/$(CDIST_CHANGELOG_VERSION)>`_"; print_new = 0; next; } { print; }' "$(WEBSITE_MAN_PAGE)" > "$(WEBSITE_MAN_PAGE)-new" && mv "$(WEBSITE_MAN_PAGE)-new" "$(WEBSITE_MAN_PAGE)" || exit 0
|
|
|
|
# Build website.
|
|
build:
|
|
$(SPHINXH)
|
|
@cd "$(WEBSITE_HTML_DIST_DIR)/manual" && rm -f latest && ln -s "$(CDIST_CHANGELOG_VERSION)" latest
|
|
|
|
release: release-prepare-latest build
|
|
|
|
release-no-latest: release-prepare build
|
|
|
|
publish:
|
|
@cd "$(WEBSITE_HTML_DIST_DIR)" \
|
|
&& tar -c -z -f "../$(WEBSITE_ARCHIVE)" . \
|
|
&& scp "../$(WEBSITE_ARCHIVE)" "$(WEBSITE_REMOTE_HOST):$(WEBSITE_REMOTE_DIR)" \
|
|
&& rm -f "../$(WEBSITE_ARCHIVE)"
|
|
@ssh "$(WEBSITE_REMOTE_HOST)" "cd $(WEBSITE_REMOTE_DIR) && tar -x -f $(WEBSITE_ARCHIVE) && rm -f $(WEBSITE_ARCHIVE)"
|
|
|
|
# Publish static website.
|
|
# Update latest symlink.
|
|
release-publish: release publish
|
|
@ssh "$(WEBSITE_REMOTE_HOST)" "cd '$(WEBSITE_REMOTE_DIR)/manual' && rm -f latest && ln -s '$(CDIST_CHANGELOG_VERSION)' latest"
|
|
|
|
release-publish-no-latest: release-no-latest publish
|
|
|
|
clean:
|
|
$(CDIST_CLEAN_HTML)
|
|
$(SPHINXC)
|