#!/bin/bash -e

# Get current verison number
version=`cat VERSION`

# Enssure we are on master branch
git checkout master

# Generate documentation
make doc
(cd doc && asciidoc index.txt)

# Checkout gh-pages
git checkout gh-pages
git pull

# Create doc folder if it does not exists
mkdir -p ./$version

# Copy doc to the right locations
cp doc/index.html ./
cp msat.docdir/* ./$version/

# Add potentially new pages
git add ./$version/*
git add ./index.html

# Commit it all & push
git commit -m "Doc release $version"
git push

# Get back to master branch
git checkout master

