-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-docs.sh
executable file
·52 lines (42 loc) · 1.26 KB
/
update-docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Based on: https://gist.github.com/Stebalien/d4a32c4abc03376db903
set -e
[[ "$(git symbolic-ref --short HEAD)" == "master" ]] || exit 0
msg() {
echo "[1;34m> [1;32m$@[0m"
}
dir="$(pwd)"
repo_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$repo_dir"
mkdir -p docs
tmp="$(mktemp -d)"
last_rev="$(git rev-parse HEAD)"
last_msg="$(git log -1 --pretty=%B)"
trap "cd \"$dir\"; rm -rf \"$tmp\"" EXIT
msg "Cloning into a temporary directory..."
git clone -qb gh-pages $repo_dir $tmp
cd "$tmp"
git checkout -q master
ln -s $repo_dir/docs $tmp/docs
msg "Installing dependencies..."
bundle install
msg "Generating documentation..."
bundle exec jazzy \
--podspec GeometryUtilities.podspec \
--theme fullwidth \
--github_url https://github.com/visualNACert/GeometryUtilities/ \
--root-url https://visualnacert.github.io/GeometryUtilities/ \
--dash-url https://visualnacert.github.io/GeometryUtilities/docsets/GeometryUtilities.xml
# Switch to pages
msg "Replacing documentation..."
git checkout -q gh-pages
# Clean and replace
git rm -q --ignore-unmatch -rf .
git reset -q -- .gitignore
git checkout -q -- .gitignore
cp -a docs/* .
rm docs
git add .
git commit -m ":memo: Update docs for $last_rev" -m "$last_msg"
git push -qu origin gh-pages
msg "Done."