krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

scripts/publish-docs.sh

ab6ccec56eca03d0dadf2c9332aab10c4490eb62
orgstar/scripts/publish-docs.sh history · blame · raw

27 lines · 895 bytes · executable

 1#!/bin/sh
 2# Builds the user manual in docs/manual with orgo and force-pushes it to the `pages`
 3# branch, which gitbay serves at https://krz.gitbay.site/orgstar/.
 4# Usage: scripts/publish-docs.sh [--dry-run]
 5set -eu
 6
 7cd "$(dirname "$0")/.."
 8tmp=$(mktemp -d)
 9trap 'rm -rf "$tmp"' EXIT
10site="$tmp/site"
11
12orgo build docs/manual -o "$site" --strict --no-cache
13rm -f "$site/.orgo-cache.json"
14
15if [ "${1:-}" = "--dry-run" ]; then
16	echo "built $(find "$site" -name '*.html' | wc -l | tr -d ' ') pages; not published"
17	exit 0
18fi
19
20# The pages branch holds only the built site, replaced on each publish.
21sha=$(git rev-parse --short HEAD)
22git init -q "$tmp/work"
23cp -R "$site/." "$tmp/work/"
24git -C "$tmp/work" add -A
25git -C "$tmp/work" commit -q -m "Publish the manual from $sha"
26git -C "$tmp/work" push -q --force "$(git remote get-url origin)" HEAD:refs/heads/pages
27echo "published the manual from $sha"