Skip to content

Commit a152e2a

Browse files
committed
Add script to publish Javadoc to GH Pages
The Javadocs are build via Gradle and pushed to the "gh-pages" branch of this repository. The script is executed by Travis CI. The variable $TRAVIS_BUILD_DIR is set by Travis CI, while $GIT_REPO_URL must be provided as secure environment variable (via Travis CI). No documentation is generated for pull requests, and to avoid that the docs are generated four times, for each build target once, it is further restricted to the "oraclejdk8" builds.
1 parent 29c3373 commit a152e2a

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ install:
2323

2424
script:
2525
- ./gradlew clean test
26+
27+
deploy:
28+
provider: script
29+
script: scripts/deploy_gh-pages.sh
30+
skip_cleanup: true
31+
on:
32+
branch: master
33+
jdk: oraclejdk8
34+
condition: "$TRAVIS_PULL_REQUEST != true"

README.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ image:https://travis-ci.org/dexX7/java-libbitcoinconsensus.svg["Build Status", l
44

55
A https://github.com/java-native-access/jna[JNA] binding and Java wrapper for https://github.com/bitcoin/bitcoin/blob/master/doc/shared-libraries.md#bitcoinconsensus[libbitcoinconsensus].
66

7+
See the http://dexx7.github.io/java-libbitcoinconsensus/[Javadoc] for an overview of this project.
8+
79
WARNING: This software is EXPERIMENTAL software. USE AT YOUR OWN RISK.
810

911
== Setup

scripts/README.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
= java-libbitcoinconsensus: scripts
2+
3+
This directory contains scripts and helpers.
4+
5+
== deploy_gh-pages.sh
6+
7+
A script used by Travis CI to generate and deploy the http://dexx7.github.io/java-libbitcoinconsensus/[Javadoc] to https://github.com/dexX7/java-libbitcoinconsensus/tree/gh-pages/[GitHub Pages].

scripts/deploy_gh-pages.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Deploying JavaDoc to GitHub Pages.."
5+
6+
# Commit hash of the main repository
7+
GIT_COMMIT=$(git rev-parse --short HEAD)
8+
9+
# Base dir of the project
10+
BUILD_DIR=$TRAVIS_BUILD_DIR
11+
12+
# The destination of the documentation
13+
DOCS_DIR=$BUILD_DIR/build/docs/javadoc
14+
15+
# Generate the JavaDoc
16+
$BUILD_DIR/gradlew --quiet clean javadoc
17+
18+
# Setup a new repository locally and commit the documentation
19+
cd $DOCS_DIR
20+
git init
21+
git config user.name "Travis CI"
22+
git config user.email "ci@bitwatch.co"
23+
git add .
24+
git commit -m "Deploy Javadoc for commit: ${GIT_COMMIT}"
25+
26+
# Force push to the remote gh-pages branch
27+
#
28+
# Note: the GIT_REPO_URL should contain the remote destination, including
29+
# OAuth access token, such as: https://1234567@github.com/user/repo.git
30+
#
31+
# The actual value is provided via Travis CI as secure environment variable:
32+
# http://docs.travis-ci.com/user/encryption-keys/
33+
# http://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
34+
#
35+
# Write access for the repository is required, and the minimum scope of
36+
# the access token is "repo". For more information about API tokens see:
37+
# https://help.github.com/articles/creating-an-access-token-for-command-line-use/
38+
#
39+
# To avoid leaking credentials, the push is silenced.
40+
git push --force --quiet $GIT_REPO_URL master:gh-pages > /dev/null 2>&1

0 commit comments

Comments
 (0)