updated deploy script

This commit is contained in:
Xavier Léauté 2014-08-01 15:12:00 -07:00
parent 6d48ffddc5
commit cd5ccc39fb
1 changed files with 35 additions and 31 deletions

View File

@ -1,43 +1,47 @@
#! /bin/bash -e
SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
if [ -z ${1} ]; then
VERSION=$(cat $SCRIPT_DIR/../../pom.xml | grep version | head -4 | tail -1 | sed 's_.*<version>\([^<]*\)</version>.*_\1_')
if [ -z "$1" ]; then
version="latest"
else
VERSION=${1}
version=$1
fi
#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"
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)
tmp=$(mktemp -d -t druid-docs-deploy)
echo Using Version [${VERSION}]
echo Script in [${SCRIPT_DIR}]
echo Deploying to [${WORKING_DIR}]
echo "Using Version [$version]"
echo "Working directory [$tmp]"
if [ -d ${WORKING_DIR} ]; then
echo DELETING ${WORKING_DIR}
rm -rf ${WORKING_DIR}
git clone https://github.com/druid-io/druid-io.github.io.git "$tmp"
docs=$(git -C$(dirname "$0") rev-parse --show-toplevel)/docs
target=$tmp/docs/$version
mkdir -p $target
rsync -a --delete "$docs/content/" $target
branch=update-docs-$version
git -C $tmp checkout -b $branch
git -C $tmp add -A .
#git -C $tmp commit -m "Update $version docs"
#git -C $tmp push origin $branch
if [ -n "$GIT_TOKEN" ]; then
curl -u "$GIT_TOKEN:x-oauth-basic" \
-XPOST https://api.github.com/repos/druid-io/druid-io.github.io/pulls -d<<EOF
{
"title" : "Update docs `$version`",
"head" : "$branch",
"base" : "master"
}
EOF
else
echo "GitHub personal token not provided, not submitting pull request"
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 .
git commit -m "Deploy ${VERSION} docs"
git push origin ${BRANCH}
popd
rm -rf ${WORKING_DIR}
#rm -rf ${tmp}