Makefile 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # requirements: git bash make python3-pip python3-venv
  2. SHELL := /bin/bash
  3. MARKDOWN_REPOSITORY = awesome-selfhosted/awesome-selfhosted
  4. HTML_REPOSITORY = awesome-selfhosted/awesome-selfhosted-html
  5. .PHONY: install # install build tools in a virtualenv
  6. install:
  7. python3 -m venv .venv
  8. source .venv/bin/activate && \
  9. pip3 install wheel && \
  10. pip3 install --force git+https://github.com/nodiscc/hecat.git@1.2.2
  11. .PHONY: import # import data from original list at https://github.com/awesome-selfhosted/awesome-selfhosted
  12. import: clean install
  13. git clone --depth=1 https://github.com/awesome-selfhosted/awesome-selfhosted
  14. cp awesome-selfhosted/AUTHORS AUTHORS
  15. rm -rf tags/ software/ platforms/
  16. mkdir -p tags/ software/ platforms/
  17. source .venv/bin/activate && \
  18. hecat --config .hecat/import.yml
  19. .PHONY: update_metadata # update metadata from project repositories/API
  20. update_metadata:
  21. source .venv/bin/activate && \
  22. hecat --config .hecat/update-metadata.yml
  23. .PHONY: awesome_lint # check data against awesome-selfhosted guidelines
  24. awesome_lint:
  25. source .venv/bin/activate && \
  26. hecat --config .hecat/awesome-lint.yml
  27. .PHONY: awesome_lint # check data against awesome-selfhosted guidelines (strict)
  28. awesome_lint_strict:
  29. source .venv/bin/activate && \
  30. hecat --config .hecat/awesome-lint-strict.yml
  31. .PHONY: export_markdown # render markdown export from YAML data (https://github.com/awesome-selfhosted/awesome-selfhosted)
  32. export_markdown:
  33. rm -rf awesome-selfhosted/
  34. git clone https://github.com/$(MARKDOWN_REPOSITORY)
  35. source .venv/bin/activate && hecat --config .hecat/export-markdown.yml
  36. cd awesome-selfhosted && git diff --color=always
  37. .PHONY: export_html # render HTML export from YAML data (https://awesome-selfhosted.net/)
  38. export_html:
  39. rm -rf awesome-selfhosted-html/ html/
  40. git clone https://github.com/$(HTML_REPOSITORY)
  41. mkdir html && source .venv/bin/activate && hecat --config .hecat/export-html.yml
  42. sed -i 's|<a href="https://github.com/pradyunsg/furo">Furo</a>|<a href="https://github.com/nodiscc/hecat/">hecat</a>, <a href="https://www.sphinx-doc.org/">sphinx</a> and <a href="https://github.com/pradyunsg/furo">furo</a>. Content under <a href="https://github.com/awesome-selfhosted/awesome-selfhosted-data/blob/master/LICENSE">CC-BY-SA 3.0</a> license. <a href="https://github.com/awesome-selfhosted/awesome-selfhosted-html">Source code</a>, <a href="https://github.com/awesome-selfhosted/awesome-selfhosted-data">raw data</a>.|' .venv/lib/python*/site-packages/furo/theme/furo/page.html
  43. source .venv/bin/activate && sphinx-build -b html -c .hecat/ html/md/ html/html/
  44. rm -rf html/html/.buildinfo html/html/objects.inv html/html/.doctrees awesome-selfhosted-html/*
  45. echo "# please do not scrape this site aggressively. Source code is available at https://github.com/awesome-selfhosted/awesome-selfhosted-html. Raw data is available at https://github.com/awesome-selfhosted/awesome-selfhosted-data" >| html/html/robots.txt
  46. .PHONY: push_markdown # commit and push changes to the markdown repository
  47. push_markdown:
  48. $(eval COMMIT_HASH=$(shell git rev-parse --short HEAD))
  49. cd awesome-selfhosted && git remote set-url origin git@github.com:$(MARKDOWN_REPOSITORY)
  50. cd awesome-selfhosted && git config user.name awesome-selfhosted-bot && git config user.email github-actions@github.com
  51. cd awesome-selfhosted && git add . && (git diff-index --quiet HEAD || git commit -m "[bot] build markdown from awesome-selfhosted-data $(COMMIT_HASH)")
  52. cd awesome-selfhosted && git push -f
  53. .PHONY: push_html # commit and push changes to the HTML site repository (amend previous commit and force-push)
  54. push_html:
  55. $(eval COMMIT_HASH=$(shell git rev-parse --short HEAD))
  56. mv html/html/* awesome-selfhosted-html/
  57. cd awesome-selfhosted-html/ && git remote set-url origin git@github.com:$(HTML_REPOSITORY)
  58. cd awesome-selfhosted-html/ && git config user.name awesome-selfhosted-bot && git config user.email github-actions@github.com
  59. cd awesome-selfhosted-html/ && git add . && (git diff-index --quiet HEAD || git commit --amend -m "[bot] build HTML from awesome-selfhosted-data $(COMMIT_HASH)")
  60. cd awesome-selfhosted-html/ && git push -f
  61. .PHONY: url_check # check URLs for dead links or other connection problems
  62. url_check:
  63. source .venv/bin/activate && \
  64. hecat --config .hecat/url-check.yml
  65. .PHONY: authors # update the AUTHORS file
  66. authors:
  67. printf "Commits|Author\n-------|---------------------------------------------------\n" > AUTHORS
  68. git shortlog -sne | grep -v awesome-selfhosted-bot >> AUTHORS
  69. .PHONY: clean # clean files generated by automated tasks
  70. clean:
  71. rm -rf awesome-selfhosted/ awesome-selfhosted-html/ html/
  72. .PHONY: help # generate list of targets with descriptions
  73. help:
  74. @grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20