diff options
| author | Egor Tensin <egor@tensin.name> | 2026-09-14 17:15:50 +0500 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-09-14 17:18:31 +0500 |
| commit | 6934a96915ea3f0c587d7755acb44e693711020b (patch) | |
| tree | cb7672038f397678d07e3ea4597ba56c0591ddfd | |
| parent | bump dependencies (diff) | |
| download | blog-6934a96915ea3f0c587d7755acb44e693711020b.tar.gz blog-6934a96915ea3f0c587d7755acb44e693711020b.zip | |
Makefile: move out maintenance stuff into a separate script
| -rw-r--r-- | Makefile | 18 | ||||
| -rwxr-xr-x | scripts/maintenance.sh | 54 |
2 files changed, 55 insertions, 17 deletions
@@ -19,23 +19,7 @@ deps: ruby .PHONY: maintenance maintenance: ruby - bundle config set frozen false - bundle update - - @git_status="$$( git status --porcelain=v1 )" && \ - if [ -z "$$git_status" ]; then \ - true; \ - elif [ "$$git_status" = ' M Gemfile.lock' ]; then \ - git commit -am 'bump dependencies' && \ - git push -q; \ - else \ - echo; \ - echo '-----------------------------------------------------------------'; \ - echo 'Error: unrecognized modifications in the repository:'; \ - echo "$$git_status"; \ - echo '-----------------------------------------------------------------'; \ - exit 1; \ - fi + ./scripts/maintenance.sh jekyll := bundle exec jekyll diff --git a/scripts/maintenance.sh b/scripts/maintenance.sh new file mode 100755 index 0000000..0a66204 --- /dev/null +++ b/scripts/maintenance.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit lastpipe + +script_path="$( readlink --canonicalize-existing -- "${BASH_SOURCE[0]}" )" +readonly script_path +script_dir="$( dirname -- "$script_path" )" +readonly script_dir + +update_gems() { + echo + echo ====================================================================== + echo Updating gems + echo ====================================================================== + bundle config set frozen false + bundle update + echo ---------------------------------------------------------------------- +} + +push_changes() { + echo + echo ====================================================================== + echo Pushing changes + echo ====================================================================== + + local git_status + git_status="$( git status --porcelain=v1 )" + + if [ -z "$git_status" ]; then + echo 'No changes.' + echo ---------------------------------------------------------------------- + return + fi + + if [ "$git_status" != ' M Gemfile.lock' ]; then + echo 'Error: unrecognized modifications in the repository:' + echo "$git_status" + echo ---------------------------------------------------------------------- + return 1 + fi + + git commit -am 'bump dependencies' + git push -q + echo ---------------------------------------------------------------------- +} + +main() { + cd -- "$script_dir/.." + update_gems + push_changes +} + +main |
