3 files changed, 69 insertions(+), 90 deletions(-)
D Justfile
A Makefile
A build.sh
D Justfile => Justfile +0 -90
@@ 1,90 0,0 @@
-DOMAIN := 'elektrubadur.se'
-IMAGE := 'elektrubadur-builder'
-
-default:
- just --list
-
-build_image:
- podman build -f Containerfile -t '{{ IMAGE }}' .
-
-_in_container *args: build_image
- podman run --rm -it \
- -v "${HOME}/.config/hut:/root/.config/hut:z" \
- -v "{{ justfile_directory() }}:{{ justfile_directory() }}:z" \
- -w "{{ justfile_directory() }}" \
- '{{ IMAGE }}' \
- just {{ args }}
-
-serve:
- podman run --rm -it \
- -v "${HOME}/.config/hut:/root/.config/hut:z" \
- -v "{{ justfile_directory() }}:{{ justfile_directory() }}:z" \
- -w "{{ justfile_directory() }}" \
- -p 1313:1313 \
- '{{ IMAGE }}' \
- hugo serve --bind 0.0.0.0
-
-_build:
- #!/bin/bash
-
- set -xeuo pipefail
-
- output_dir=''{{ justfile_directory() }}/public''
-
- rm -rf "${output_dir}"
-
- hugo --baseURL='https://{{ DOMAIN }}'
-
- find "${output_dir}" -type f -iname '*.html' \
- -exec tidy \
- --quiet yes \
- --show-warnings no \
- --tidy-mark no \
- --vertical-space no \
- --wrap 0 \
- --write-back yes \
- {} '+' \
- || (($?==1 ? 1 : 0))
-
- find "${output_dir}" -type f -iname '*.xml' | while read f; do
- tempfile="$(mktemp -t "$(basename "${f}")".XXXXXXXX)"
- xmlstarlet fo \
- --noindent \
- --nocdata \
- --nsclean \
- --encode utf-8 \
- "${f}" > "${tempfile}" && mv -v "${tempfile}" "${f}"
- done
-
-build:
- @just _in_container _build
-
-validate: build
- podman run --rm -it \
- -v "{{ justfile_directory() }}:{{ justfile_directory() }}:z" \
- -w "{{ justfile_directory() }}" \
- ghcr.io/validator/validator:latest \
- vnu --skip-non-html public
-
-package: build validate
- tar -C public -czf public.tar.gz .
-
-_publish:
- hut pages publish --domain '{{ DOMAIN }}' --site-config ./site-config.json public.tar.gz
-
-publish: package
- just _in_container _publish
-
-package_redirect:
- tar -C redirect -czf redirect.tar.gz .
-
-_publish_redirect domain: package_redirect
- hut pages publish --domain '{{ domain }}' --site-config ./site-config-redirect.json redirect.tar.gz
-
-publish_redirects:
- just _in_container _publish_redirect www.elektrubadur.se
- just _in_container _publish_redirect bkhl.elektrubadur.se
- just _in_container _publish_redirect bkhl.srht.site
-
-check_links:
- podman run --rm docker.io/tennox/linkcheck --external '{{ DOMAIN }}'
A Makefile => Makefile +41 -0
@@ 0,0 1,41 @@
+IMAGE := localhost/elektrubadur-builder:latest
+
+export DOMAIN := elektrubadur.se
+export OUTPUT_DIR := public
+
+PODMAN := podman run --rm -it \
+ --volume "$(HOME)/.config/hut:/root/.config/hut:z" \
+ --volume "$(CURDIR):$(CURDIR):z" \
+ --workdir "$(CURDIR)"
+
+.PHONY: all image build serve validate package publish package_redirect publish_redirect check_links
+
+all:
+ make --print-targets
+
+image:
+ podman build -f Containerfile -t $(IMAGE) .
+
+build: image
+ $(PODMAN) --env DOMAIN --env OUTPUT_DIR $(IMAGE) bash build.sh
+
+serve: image
+ $(PODMAN) --publish '1313:1313' $(IMAGE) hugo serve --bind 0.0.0.0
+
+validate: build
+ $(PODMAN) ghcr.io/validator/validator:latest vnu --skip-non-html public
+
+package: build validate
+ tar -C public -czf public.tar.gz .
+
+publish: package
+ $(PODMAN) $(IMAGE) hut pages publish --domain $(DOMAIN) --site-config ./site-config.json public.tar.gz
+
+package_redirect:
+ tar -C redirect -czf redirect.tar.gz .
+
+publish_redirect: package_redirect
+ for domain in www.elektrubadur.se bkhl.elektrubadur.se bkhl.srht.site; do $(PODMAN) $(IMAGE) hut pages publish --domain $$domain --site-config ./site-config-redirect.json redirect.tar.gz; done
+
+check_links:
+ $(PODMAN) docker.io/tennox/linkcheck:latest --external $(DOMAIN)
A build.sh => build.sh +28 -0
@@ 0,0 1,28 @@
+#!/bin/bash
+
+set -xeuo pipefail
+
+rm -rf "${OUTPUT_DIR}"
+
+hugo --baseURL="https://${DOMAIN}"
+
+find "${OUTPUT_DIR}" -type f -iname '*.html' \
+ -exec tidy \
+ --quiet yes \
+ --show-warnings no \
+ --tidy-mark no \
+ --vertical-space no \
+ --wrap 0 \
+ --write-back yes \
+ {} '+' \
+ || (($?==1 ? 1 : 0))
+
+find "${OUTPUT_DIR}" -type f -iname '*.xml' | while read f; do
+ tempfile="$(mktemp -t "$(basename "${f}")".XXXXXXXX)"
+ xmlstarlet fo \
+ --noindent \
+ --nocdata \
+ --nsclean \
+ --encode utf-8 \
+ "${f}" > "${tempfile}" && mv -v "${tempfile}" "${f}"
+done