Created
April 6, 2012 23:58
-
-
Save lightningdb/2324137 to your computer and use it in GitHub Desktop.
Publish documentation to directory reflecting tag or branch in gh-pages branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get current branch and tag | |
branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`; | |
tag=`git describe --tags`; | |
# if current tag has annotations showing number of commits since tagging, then use current branch | |
destination="$tag" | |
if [[ "$tag" == *-* ]] | |
then | |
echo "extra commits since last tag!"; | |
destination="$branch" | |
fi | |
# source and destination will be same, separate variables for clarity | |
src_tag_or_branch=$destination | |
echo "destination: $destination" | |
# then git checkout gh-pages and go to top level dir | |
git checkout gh-pages && cd $(git rev-parse --show-toplevel) | |
# then mkdir for current branch or tag | |
mkdir -p $destination | |
# then copy doc files to current branch under a directory for current tag/branch | |
git archive --format=tar --prefix=$destination/ $src_tag_or_branch:docs | tar -xf - | |
# then commit new docs with message | |
git add . | |
git commit -m "updated docs from $src_tag_or_branch for $destination" | |
# return to original branch | |
git checkout $branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment