File: update-gh-pages-for-tag

package info (click to toggle)
ocaml-thread-table 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 148 kB
  • sloc: ml: 202; sh: 59; makefile: 3
file content (75 lines) | stat: -rwxr-xr-x 1,405 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

set -xeuo pipefail

TMP=tmp
NAME=thread-table
MAIN=doc
GIT="git@github.com:ocaml-multicore/$NAME.git"
DOC="_build/default/_doc/_html"
GH_PAGES=gh-pages

TAG="$1"

if ! [ -e $NAME.opam ] || [ $# -ne 1 ] || \
     { [ "$TAG" != main ] && ! [ "$(git tag -l "$TAG")" ]; }; then
  CMD="${0##*/}"
  cat << EOF
Usage: $CMD tag-name-or-main

This script
- clones the repository into a temporary directory ($TMP/$NAME),
- builds the documentation for the specified tag or main,
- updates $GH_PAGES branch with the documentation in directory for the tag,
- prompts whether to also update the main documentation in $MAIN directory, and
- prompts whether to push changes to $GH_PAGES.

EOF
  exit 1
fi

mkdir $TMP
cd $TMP

git clone $GIT
cd $NAME

git checkout "$TAG"
dune build @doc --root=.

git checkout $GH_PAGES
if [ "$TAG" != main ]; then
  echo "Updating the $TAG doc."
  if [ -e "$TAG" ]; then
    git rm -rf "$TAG"
  fi
  cp -r $DOC "$TAG"
  git add "$TAG"
fi

read -p "Update the main doc? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
  if [ -e $MAIN ]; then
    git rm -rf $MAIN
  fi
  cp -r $DOC $MAIN
  git add $MAIN
else
  echo "Skipped main doc update."
fi

git commit -m "Update $NAME doc for $TAG"

read -p "Push changes to $GH_PAGES? (y/N) " -n 1 -r
echo
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
  echo "Leaving $TMP for you to examine."
  exit 1
fi

git push

cd ..
cd ..
rm -rf $TMP