diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..088a9e1 --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ +all: + make site + make migration + +site: + mkdir --parents public/posts + ln -sfT ../../public/posts generators/hugo/public + cd generators/hugo && hugo + +migration: + sqlite3 database/sqlite.db < database/contactform.sql + chmod g+w database/sqlite.db + sed --in-place "s|'sql:;dbname=sql_database'|'sqlite:' . __DIR__ . '/database/sqlite.db'|" config.php + +permissions: + find . -type f -print0 | xargs -0 chmod 640 + find . -type d -print0 | xargs -0 chmod 770 + +export date := $(shell date -Iseconds) +export path := deploy-$(date) +export deployment := $(target)/$(path) +export prelaunch := $(target)/prelaunch +export public := $(target)/public + +deploy: + mkdir --parent '$(deployment)' + rsync --archive --verbose \ + --exclude='.git/' \ + --exclude='.gitignore' \ + --exclude='$(target)/' \ + . '$(deployment)' + ln --symbolic --force '$(path)/public' '$(prelaunch)' + make minify + make cache + cd '$(deployment)' && make site + make permissions + cd '$(deployment)' && make migration + mv --force --no-target-directory '$(prelaunch)' '$(public)' + find '$(target)' -maxdepth 1 ! -path '$(target)' -type d -printf '%T@\t%p\n' \ + | sort --reverse --general-numeric-sort --field-separator $$'\t' \ + | cut --delimiter $$'\t' --fields 2- \ + | awk "NR>5" \ + | xargs rm -rf + +cache: + { [ -e '$(public)' ] && \ + rsync --verbose --archive --include="*/" --include="*.min.*" --exclude="*" '$(public)/dist/' '$(prelaunch)/dist'; \ + rsync --verbose --archive '$(public)/../bootstrap/comments/comments/' '$(prelaunch)/../bootstrap/comments/comments'; \ + rsync --verbose --archive '$(public)/../database/sqlite.db' '$(prelaunch)/../database/sqlite.db'; \ + } || true + +minify: + minify $(prelaunch)/dist/app.css > $(prelaunch)/dist/app.min.'$(date)'.css + minify $(prelaunch)/dist/bar-ui.css > $(prelaunch)/dist/bar-ui-css.min.'$(date)'.css + minify $(prelaunch)/dist/bar-ui.js > $(prelaunch)/dist/bar-ui-js.min.'$(date)'.js + find $(prelaunch) -type f -exec sed --in-place "s|$$(find $(prelaunch)/dist -name "app.min*" | awk -F/ '{print $NF}')|" {} \; + find $(prelaunch) -type f -exec sed --in-place "s|$$(find $(prelaunch)/dist -name "bar-ui-css.min*" | awk -F/ '{print $NF}')|" {} \; + find $(prelaunch) -type f -exec sed --in-place "s|$$(find $(prelaunch)/dist -name "bar-ui-js.min*" | awk -F/ '{print $NF}')|" {} \; + +.PHONY: generators admin |