druid/docs/_bin/deploy-docs.sh

44 lines
1014 B
Bash
Raw Normal View History

2013-09-27 21:50:02 -04:00
#! /bin/bash -e
2013-11-05 18:20:55 -05:00
SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
2013-09-27 21:50:02 -04:00
if [ -z ${1} ]; then
2013-11-05 18:20:55 -05:00
VERSION=$(cat $SCRIPT_DIR/../../pom.xml | grep version | head -4 | tail -1 | sed 's_.*<version>\([^<]*\)</version>.*_\1_')
2013-09-27 21:50:02 -04:00
else
VERSION=${1}
fi
2013-11-05 18:20:55 -05:00
#if [ -z "$(git tag -l "druid-$VERSION")" ]
if [ -z "$(git tag -l "druid-$VERSION")" ] && [ "$VERSION" != "latest" ]; then
echo "Version tag does not exist: druid-$VERSION"
exit 1;
fi
WORKING_DIR=$(mktemp -d -t druid-docs-deploy)
2013-09-27 21:50:02 -04:00
2013-11-05 18:20:55 -05:00
echo Using Version [${VERSION}]
2013-09-27 21:50:02 -04:00
echo Script in [${SCRIPT_DIR}]
echo Deploying to [${WORKING_DIR}]
if [ -d ${WORKING_DIR} ]; then
echo DELETING ${WORKING_DIR}
rm -rf ${WORKING_DIR}
fi
git clone git@github.com:druid-io/druid-io.github.io.git ${WORKING_DIR}
DOC_DIR=${WORKING_DIR}/docs/${VERSION}/
mkdir -p ${DOC_DIR}
cp -r ${SCRIPT_DIR}/../content/* ${DOC_DIR}
BRANCH=docs-${VERSION}
pushd ${WORKING_DIR}
git checkout -b ${BRANCH}
git add .
2013-11-05 18:20:55 -05:00
git commit -m "Deploy ${VERSION} docs"
2013-09-27 21:50:02 -04:00
git push origin ${BRANCH}
popd
rm -rf ${WORKING_DIR}