My personal website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6KB

  1. #!/usr/bin/env bash
  2. # Source Themes Academic: Theme updater
  3. # Checks for available updates and then asks to install any updates.
  4. # https://sourcethemes.com/academic/
  5. #
  6. # Command: bash ./update_academic.sh
  7. # Check for prerequisites.
  8. if [ ! -d .git ]; then
  9. echo "ERROR: This tool is for Git repositories only."
  10. exit 1;
  11. fi
  12. function view_update () {
  13. echo -e "Checking for updates...\n"
  14. cd themes/academic
  15. git fetch
  16. git log --pretty=oneline --abbrev-commit --decorate HEAD..origin/master
  17. cd ../../
  18. }
  19. # Function to update Academic
  20. function do_update () {
  21. # Apply any updates
  22. git submodule update --remote --merge
  23. # - Update Netlify.toml with required Hugo version
  24. if [ -f ./netlify.toml ]; then
  25. # Postfix '.0' to Hugo min_version as sadly it doesn't map to a precise semantic version.
  26. version=$(sed -n 's/^min_version = //p' themes/academic/theme.toml | tr -d '"')
  27. version="${version}.0"
  28. echo "Set Netlify Hugo version to v${version}"
  29. sed -i.bak -e "s/HUGO_VERSION = .*/HUGO_VERSION = \"$version\"/g" ./netlify.toml && rm -f ./netlify.toml.bak
  30. fi
  31. echo
  32. echo "View the release notes at: https://sourcethemes.com/academic/updates"
  33. echo "If there are breaking changes, the config and/or front matter of content" \
  34. "may need upgrading by following the steps in the release notes."
  35. }
  36. # Display currently installed version (although could be between versions if updated to master rather than tag)
  37. version=$(sed -n 's/^version = "//p' themes/academic/data/academic.toml)
  38. echo -e "Source Themes Academic v$version\n"
  39. # Display available updates
  40. view_update
  41. # Apply any updates
  42. do_update