Skip to content

Commit 22f71f5

Browse files
authored
Merge pull request #27 from IBM/build-javadoc-ci
Add release docs to GH pages site on releases
2 parents 2b298a8 + ddbe0bf commit 22f71f5

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ deploy:
5454
skip_cleanup: true
5555
on:
5656
tags: true
57+
- provider: script
58+
script: "./build/push-javadoc-to-gh-pages.sh"
59+
skip_cleanup: true
60+
on:
61+
tags: true
5762

5863
# Ask bintray to sync the just-deployed artifact to maven central
5964
after_script:

build/generate-index-html.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
# based on https://odoepner.wordpress.com/2012/02/17/shell-script-to-generate-simple-index-html/
4+
5+
echo '<!DOCTYPE html>
6+
<html>
7+
<head>
8+
<meta charset="utf-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<title>IBM Java SDK Core</title>
12+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
13+
</head>
14+
<body>
15+
<div class="container">
16+
<div class="page-header">
17+
<h1>IBM Java SDK Core</h1>
18+
</div>
19+
20+
<p>Javadoc by branch/tag:</p>
21+
<ul>'
22+
ls docs | grep --invert-match index.html | sed 's/^.*/<li><a href="docs\/&">&<\/a><\/li>/'
23+
echo ' </ul>
24+
</div>
25+
<script>
26+
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
27+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
28+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
29+
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
30+
ga("create", "UA-59827755-4", "auto");
31+
ga("send", "pageview");
32+
</script>
33+
</body>
34+
</html>'

build/push-javadoc-to-gh-pages.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then
4+
5+
git clone --quiet --branch=gh-pages https://${GITHUB_OAUTH_TOKEN}@github.com/IBM/java-sdk-core.git gh-pages > /dev/null
6+
7+
pushd gh-pages
8+
# on tagged builds, $TRAVIS_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master)
9+
rm -rf docs/$TRAVIS_BRANCH
10+
mkdir -p docs/$TRAVIS_BRANCH
11+
cp -rf ../target/apidocs/* docs/$TRAVIS_BRANCH
12+
../.utility/generate_index_html.sh > index.html
13+
14+
git add -f .
15+
git commit -m "Latest javadoc for $TRAVIS_BRANCH ($TRAVIS_COMMIT)"
16+
git push -fq origin gh-pages > /dev/null
17+
18+
popd
19+
20+
echo -e "Published Javadoc for build $TRAVIS_BUILD_NUMBER ($TRAVIS_JOB_NUMBER) on branch $TRAVIS_BRANCH.\n"
21+
22+
else
23+
24+
echo -e "Not publishing docs for build $TRAVIS_BUILD_NUMBER ($TRAVIS_JOB_NUMBER) on branch $TRAVIS_BRANCH of repo $TRAVIS_REPO_SLUG"
25+
26+
fi

0 commit comments

Comments
 (0)