# requirements: git bash make python3-pip python3-venv
SHELL := /bin/bash
MARKDOWN_REPOSITORY = nodiscc/awesome-selfhosted
HTML_REPOSITORY = nodiscc/awesome-selfhosted-html-preview
.PHONY: install # install build tools in a virtualenv
install:
python3 -m venv .venv
source .venv/bin/activate && \
pip3 install wheel && \
pip3 install --force git+https://github.com/nodiscc/hecat.git@master 'sphinx<7'
.PHONY: import # import data from original list at https://github.com/awesome-selfhosted/awesome-selfhosted
import: clean install
git clone --depth=1 https://github.com/awesome-selfhosted/awesome-selfhosted
cp awesome-selfhosted/.github/.mailmap .mailmap
cp awesome-selfhosted/AUTHORS AUTHORS
rm -rf tags/ software/ platforms/
mkdir -p tags/ software/ platforms/
source .venv/bin/activate && \
hecat --config .hecat/import.yml
.PHONY: update_metadata # update metadata from project repositories/API
update_metadata: install
source .venv/bin/activate && \
hecat --config .hecat/update-metadata.yml
.PHONY: awesome_lint # check data against awesome-selfhosted guidelines
awesome_lint: install
source .venv/bin/activate && \
hecat --config .hecat/awesome-lint.yml
.PHONY: export_markdown # render markdown export from YAML data (https://github.com/awesome-selfhosted/awesome-selfhosted)
export_markdown: install
rm -rf awesome-selfhosted/
git clone https://github.com/$(MARKDOWN_REPOSITORY)
source .venv/bin/activate && hecat --config .hecat/export-markdown.yml
cd awesome-selfhosted && git diff --color=always
.PHONY: export_html # render HTML export from YAML data (https://nodiscc.github.io/awesome-selfhosted-html-preview/)
export_html: install
rm -rf awesome-selfhosted-html-preview/ html/
git clone https://github.com/$(HTML_REPOSITORY)
mkdir html && source .venv/bin/activate && hecat --config .hecat/export-html.yml
sed -i 's|Furo|hecat, sphinx and furo. Content under CC-BY-SA 3.0 license.|' .venv/lib/python*/site-packages/furo/theme/furo/page.html
source .venv/bin/activate && sphinx-build -b html -c ./ html/md/ html/html/
rm -rf html/html/.buildinfo html/html/objects.inv html/html/.doctrees awesome-selfhosted-html-preview/*
.PHONY: push_markdown # commit and push changes to the markdown repository
push_markdown:
cd awesome-selfhosted && git remote set-url origin git@github.com:$(MARKDOWN_REPOSITORY)
cd awesome-selfhosted && git config user.name awesome-selfhosted-bot && git config user.email github-actions@github.com
cd awesome-selfhosted && git add . && (git diff-index --quiet HEAD || git commit -m "[bot] build markdown repository")
cd awesome-selfhosted && git push -f
.PHONY: push_html # commit and push changes to the HTML site repository (amend previous commit and force-push)
push_html:
mv html/html/* awesome-selfhosted-html-preview/
cd awesome-selfhosted-html-preview/ && git remote set-url origin git@github.com:$(HTML_REPOSITORY)
cd awesome-selfhosted-html-preview/ && git config user.name awesome-selfhosted-bot && git config user.email github-actions@github.com
cd awesome-selfhosted-html-preview/ && git add . && (git diff-index --quiet HEAD || git commit --amend -m "[bot] build HTML site")
cd awesome-selfhosted-html-preview/ && git push -f
.PHONY: url_check # check URLs for dead links or other connection problems
url_check: install
source .venv/bin/activate && \
hecat --config .hecat/url-check.yml
.PHONY: authors # update the AUTHORS file
authors:
printf "Commits|Author\n-------|---------------------------------------------------\n" > AUTHORS
git shortlog -sne >> AUTHORS
.PHONY: clean # clean files generated by automated tasks
clean:
rm -rf awesome-selfhosted/ awesome-selfhosted-html-preview/ html/
.PHONY: help # generate list of targets with descriptions
help:
@grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20