tasks.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from invoke import task
  2. @task
  3. def clean(c):
  4. """Remove all artefacts."""
  5. patterns = ["build", "docs/build"]
  6. for pattern in patterns:
  7. c.run(f"rm -rf {pattern}")
  8. @task(name="docs", aliases=("html", "documentation"))
  9. def docs_html(c, output_directory="build/html"):
  10. """Build the documentation in HTML form."""
  11. c.run(f"python3 -m sphinx docs {output_directory}")
  12. @task
  13. def release(c, version):
  14. """"""
  15. if version not in ["minor", "major", "patch"]:
  16. print("Version can be either major, minor or patch.")
  17. return
  18. from docs import __version_info__, __version__
  19. _major, _minor, _patch = __version_info__
  20. if version == "patch":
  21. _patch = _patch + 1
  22. elif version == "minor":
  23. _minor = _minor + 1
  24. _patch = 0
  25. elif version == "major":
  26. _major = _major + 1
  27. _minor = 0
  28. _patch = 0
  29. c.run(f"git checkout -b release-{_major}.{_minor}.{_patch} dev")
  30. c.run(f"sed -i 's/{__version__}/{_major}.{_minor}.{_patch}/g' docs/__init__.py")
  31. print(f"Update the readme for version {_major}.{_minor}.{_patch}.")
  32. input("Press enter when ready.")
  33. c.run(f"git add -u")
  34. c.run(f'git commit -m "Update changelog version {_major}.{_minor}.{_patch}"')
  35. c.run(f"git push --set-upstream origin release-{_major}.{_minor}.{_patch}")
  36. c.run(f"git checkout main")
  37. c.run(f"git merge --no-ff release-{_major}.{_minor}.{_patch}")
  38. c.run(f'git tag -a {_major}.{_minor}.{_patch} -m "Release {_major}.{_minor}.{_patch}"')
  39. c.run(f"git push")
  40. c.run(f"git checkout dev")
  41. c.run(f"git merge --no-ff release-{_major}.{_minor}.{_patch}")
  42. c.run(f"git push")
  43. c.run(f"git branch -d release-{_major}.{_minor}.{_patch}")
  44. c.run(f"git push origin --tags")
  45. @task
  46. def local(c):
  47. """"""
  48. c.run("mkdir -p config data docs drawio fuseki fuseki-extra")
  49. c.run("docker-compose -f local.yml build")
  50. c.run("docker-compose -f local.yml up")