#!/bin/bash

echo "Note: give a version on the command line to customize the version included in the documentation."

if [[ $# -gt 0 ]]
then
    version="$1"
    date=$(git for-each-ref "refs/tags/release/${version}" --format="%(taggerdate:iso)" | cut -d" " -f 1)
else
    version=$(find_version)
    date=$(git show --pretty='%cI' HEAD | head -n 1 | cut -d"T" -f 1)
fi

if [[ "$date" == "" ]]
then
    echo "Error: No date for the specified version!"
    exit 1
fi

echo "Building documentation for ${version}, ${date}"

release-build-doc "$version" "$date" || exit 1
cat release/doc.tar.gz | ssh filip-www@fprg.se /home/filip-www/upload-doc.sh
