-
Notifications
You must be signed in to change notification settings - Fork 13
/
generate-site.sh
executable file
·48 lines (34 loc) · 1.43 KB
/
generate-site.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
#!/bin/sh
die() {
echo "$1"
exit 1
}
REPO=https://github.com/InMobi/conduit
TMP=/tmp/conduit-site-stage
STAGE=`pwd`/target/staging
VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version|grep -Ev '(^\[|Download\w+:)' || die "unable to get version")
mvn clean install -DskipTests
mvn clean site site:stage || die "unable to generate site"
rm -rf $TMP || die "unable to clear $TMP"
git clone $REPO $TMP || die "unable to clone $TMP"
cd $TMP
git checkout gh-pages || die "unable to checkout gh-pages"
mkdir -p current || die "unable to create dir current"
mkdir -p versions/$VERSION || die "unable to create dir versions/$VERSION"
find current -type f -exec git rm {} \;
mkdir -p current || die "unable to create dir current"
mkdir -p versions/$VERSION || die "unable to create dir versions/$VERSION"
cp -r $STAGE/* current/ || die "unable to copy to current"
cp -r $STAGE/* versions/$VERSION/ || die "unable to copy to versions/$VERSION"
FILES=$(cd versions; ls -t | grep -v index.html)
echo '<ul>' > versions/index.html
for f in $FILES
do
echo "<li><a href='$f/index.html'>$f</a></li>" >> versions/index.html
done
echo '</ul>' >> versions/index.html
git add . || die "unable to add for commit"
git commit -m "updated documentation for version $VERSION" || die "unable to commit to git"
git push origin gh-pages || die "unable to push to gh-pages"
cd $STAGE
rm -rf $TMP || die "unabel to clear $TMP"