forked from angular/protractor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-docs.sh
More file actions
executable file
·51 lines (45 loc) · 1.53 KB
/
generate-docs.sh
File metadata and controls
executable file
·51 lines (45 loc) · 1.53 KB
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
#!/bin/sh
cd "$( dirname "${BASH_SOURCE[0]}" )/../website"
# Check that directory is clean
if [ $(git status --porcelain | wc -l) != "0" ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "We cannot push the generated docs unless the working directory is" 1>&2
echo "clean. Either commit your changes, stash them, or generate the" 1>&2
echo "docs manually by running gulp in /website/ and push them to" 1>&2
echo "gh-pages at a later date" 1>&2
echo -e "\033[0m" 1>&2 # Normal color
exit 1
fi
# Switch to the branch were the version was bumped
VERSION=$(node ../scripts/get-version.js)
EXEC_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git checkout "${VERSION}"
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "The package.json file indicates that the current version is" 1>&2
echo "\"${VERSION}\", but there is no corresponding git tag" 1>&2
echo -e "\033[0m" 1>&2 # Normal Color
exit 1
fi
# Generate files
npm run build
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Build failed. Try running 'npm install' in /website/." 1>&2
echo -e "\033[0m" 1>&2 # Normal Color
exit 1
fi
# Transfer files to gh-pages
cd ".."
git branch -D gh-pages
git branch gh-pages
git checkout gh-pages
git pull https://github.com/angular/protractor.git gh-pages:gh-pages -f
git reset --hard
cp -r website/build/* .
git add -A
git commit -m "chore(website): automatic docs update for ${VERSION}"
echo -e "\033[0;32m" # Green
echo "Created update commit in gh-pages branch"
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"