aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-09-14 16:56:24 +0500
committerEgor Tensin <egor@tensin.name>2026-09-14 17:05:29 +0500
commitea3a5b3e4c74436504afc9f10c153f416e48c3d2 (patch)
tree486f288f4a386133812eebdf34395eda1a9d4032
parentbump dependencies (diff)
downloadwireguard-config-ea3a5b3e4c74436504afc9f10c153f416e48c3d2.tar.gz
wireguard-config-ea3a5b3e4c74436504afc9f10c153f416e48c3d2.zip
Makefile: move out maintenance stuff into a separate script
-rw-r--r--Makefile28
-rwxr-xr-xscripts/maintenance.sh76
2 files changed, 77 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index 6cfa5ae..a09d80d 100644
--- a/Makefile
+++ b/Makefile
@@ -18,35 +18,9 @@ deps: ruby
bundle install
npm install
-.PHONY: browserify
-browserify: src/assets/js/bundle.js
-
-src/assets/js/bundle.js: package-lock.json
- npm exec -- browserify --require ip-address --outfile '$(call escape,$@)'
-
.PHONY: maintenance
maintenance: ruby
- bundle config set frozen false
- bundle update
-
- npm update
- @$(MAKE) browserify
-
- @git_status="$$( git status --porcelain=v1 )" && \
- allowed=' M Gemfile.lock| M package-lock.json| M src/assets/js/bundle.js' && \
- if [ -z "$$git_status" ]; then \
- true; \
- elif ! echo "$$git_status" | grep -E -q --invert-match --line-regexp "($$allowed)"; 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..1facc05
--- /dev/null
+++ b/scripts/maintenance.sh
@@ -0,0 +1,76 @@
+#!/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 ----------------------------------------------------------------------
+}
+
+update_npm_packages() {
+ echo
+ echo ======================================================================
+ echo Updating npm packages
+ echo ======================================================================
+ npm update
+ echo ----------------------------------------------------------------------
+}
+
+browserify() {
+ echo
+ echo ======================================================================
+ echo Running Browserify
+ echo ======================================================================
+ npm exec -- browserify --require ip-address --outfile src/assets/js/bundle.js
+ 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
+
+ local allowed=' M Gemfile.lock| M package-lock.json| M src/assets/js/bundle.js'
+
+ if echo "$git_status" | grep -E -q --invert-match --line-regexp "($allowed)" ; 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
+ update_npm_packages
+ browserify
+ push_changes
+}
+
+main