forked from music-encoding/music-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-docs.sh
executable file
·77 lines (57 loc) · 2.23 KB
/
deploy-docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# This script builds the documentation and automatically commits
# it to the 'guidelines' directory.
# It uses an encrypted GH_TOKEN setting in Travis to check out the Guidelines, build them, commit
# the changes, and then push.
#
# Changes to the major version of MEI should be reflected by updating the MEI_VERSION variable.
set -e # Exit with nonzero exit code if anything fails
MEI_VERSION="v4"
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
echo "Will not build docs for pull requests. Skipping deploy."
exit 0
fi
# if [ "${TRAVIS_BRANCH}" == "develop" ]; then
# OUTPUT_FOLDER="dev"
# DOCS_BRANCH="master"
if [ "${TRAVIS_BRANCH}" == "master" ]; then
OUTPUT_FOLDER=${MEI_VERSION}
DOCS_BRANCH="master"
else
echo "Will not build docs for branch ${TRAVIS_BRANCH}"
exit 0
fi
# Get the music-encoding revision
SHA=`git rev-parse --verify HEAD`
SHORT_SHA=`git rev-parse --verify --short HEAD`
DOCS_REPOSITORY="https://${GH_USERNAME}:${GH_TOKEN}@github.com/music-encoding/guidelines"
DOCS_DIRECTORY="guidelines-repo"
DOCS_VERSION_BUILD_FILE="${DOCS_DIRECTORY}/_includes/${OUTPUT_FOLDER}/build.txt"
BUILD_DIR="build"
CANONICALIZED_SCHEMA="${BUILD_DIR}/mei-canonicalized.xml"
# Clone the docs repo.
echo "Cloning ${DOCS_REPOSITORY}"
git clone ${DOCS_REPOSITORY} ${DOCS_DIRECTORY}
echo "Running documentation build"
echo "<a href='https://github.com/music-encoding/music-encoding/commit/${SHA}'>Version ${SHORT_SHA}</a>" > ${DOCS_VERSION_BUILD_FILE}
cd ${DOCS_DIRECTORY}
echo "Checking out ${DOCS_BRANCH} branch"
git checkout ${DOCS_BRANCH}
# cd to tools since the xslt is configured to write relative to this directory
cd tools
echo "Building docs"
java -jar ${PATH_TO_SAXON_JAR} -xsl:extractGuidelines.xsl guidelines.version=${OUTPUT_FOLDER} ../../${CANONICALIZED_SCHEMA}
# change back to root of guidelines to commit.
cd ..
ls -alh
echo "Configuring git push"
git config user.name "Documentation Builder"
git config user.email "${COMMIT_AUTHOR_EMAIL}"
git status
git add -A
git commit -m "Auto-commit of documentation build for music-encoding/music-encoding@${SHA}"
echo "Syncing from origin..."
git pull
echo "Pushing commits"
# Now that we're all set up, we can push.
git push ${DOCS_REPOSITORY} ${DOCS_BRANCH}