diff options
author | George Cushen <gcushen@users.noreply.github.com> | 2020-09-21 00:14:51 +0300 |
---|---|---|
committer | George Cushen <gcushen@users.noreply.github.com> | 2020-09-21 00:14:58 +0300 |
commit | 38f17bd226c4fa2e1d91f7313708ca9a1f43b925 (patch) | |
tree | 10a853627cf5f51a03a43a3f160a019a5b5ad01c /update_wowchemy.sh | |
parent | 874ed28155839dd1a6928996087f69c8f244a44f (diff) |
feat: update update script from Git Modules to Hugo Modules
Diffstat (limited to 'update_wowchemy.sh')
-rwxr-xr-x | update_wowchemy.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/update_wowchemy.sh b/update_wowchemy.sh new file mode 100755 index 00000000..fdc57279 --- /dev/null +++ b/update_wowchemy.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Wowchemy Updater +# Checks for available updates and then asks to install any updates. +# https://wowchemy.com/docs/update/ +# +# Command: bash ./update_wowchemy.sh + +# Check for prerequisites. +if [ ! -d content ]; then + echo "ERROR: `cd` into your website folder before running this tool." + exit 1; +fi + +# Update the Wowchemy Hugo module +function update_wowchemy () { + # Update Wowchemy to the latest master version + echo -e "Updating Wowchemy to the latest master version...\n" + hugo mod get github.com/wowchemy/wowchemy-hugo-modules/wowchemy/@master + hugo mod tidy +} + +# Update Netlify config +function update_netlify () { + # - Update Netlify.toml with required Hugo version + if [ -f ./netlify.toml ]; then + curl -o "tmp_get_version" https://raw.githubusercontent.com/wowchemy/wowchemy-hugo-modules/master/wowchemy/config.toml + version=$(sed -n 's/^[[:space:]]*min = //p' "tmp_get_version" | tr -d '"') + version="${version}" + echo "Set Netlify Hugo version to v${version}" + sed -i.bak -e "s/HUGO_VERSION = .*/HUGO_VERSION = \"$version\"/g" ./netlify.toml && rm -f ./netlify.toml.bak + rm tmp_get_version + fi +} + +# Perform update +update_wowchemy +update_netlify + +echo +echo "If there are breaking changes, the config and/or front matter of content" \ +"may need upgrading by following the steps in the relevant consecutive release notes." +echo +echo "View the update guide at: https://wowchemy.com/docs/update/" +echo "View the latest release notes at: https://wowchemy.com/updates/" |