-
Notifications
You must be signed in to change notification settings - Fork 1
/
javadocs
executable file
·73 lines (51 loc) · 1.8 KB
/
javadocs
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
#!/bin/bash
# Check if enough arguments have been given to the script.
if [[ $# < 3 ]]; then
echo "Usage: $0 <name> <command> <dir> [Travis-JDK]"
echo "e.g.: $0 project \"./gradlew javadoc\" build/docs/javadoc"
exit 1
fi
GIT_REPO="[email protected]:LapisBlue/Javadocs.git"
GIT_DIR=/tmp/deploy/javadocs
# This is where I am.
deploy_scripts=$(dirname $0)
# The name of the project, represents the folder in the repository.
name=$1
# The command to execute that will generate the Javadocs.
command=$2
# Folders
root_dir=$(pwd)
dir=$3
# JDK to create the Javadocs with, Java 8 by default
jdk=${4:-oraclejdk8}
# Ensure all commands complete successfully
set -e
# Make sure we're running the right Travis JDK version
[[ -z "$TRAVIS_JDK_VERSION" || "$TRAVIS_JDK_VERSION" = "$jdk" ]]
# Initialize the ssh-agent so we can use Git later for deploying
eval $(ssh-agent)
# Set up our Git environment
$deploy_scripts/setup_git
echo "Building Javadocs..."
# Run the specified command to build the Javadocs
$command
echo "Completed Javadoc generation, deploying to GitHub..."
# Clone our Javadocs repository
git clone $GIT_REPO $GIT_DIR
cd $GIT_DIR
echo "Javadoc location for this project: $GIT_DIR/$name"
# Delete the old Javadocs so we have them completely clean again
git rm -r $name
# Copy the new generated Javadocs and add them to Git
cp -r $root_dir/$dir $name
git add -A
# Commit the changes with a more detailed commit message only for Travis.
[[ "$TRAVIS" = "true" ]] \
&& message="Update to $TRAVIS_REPO_SLUG@$TRAVIS_COMMIT (Build $TRAVIS_BUILD_NUMBER)" \
|| message="Update $(date -u +"%Y-%m-%dT%H:%M:%SZ")" # -> ugly date
git commit -m "$message"
# Push the changes to GitHub
git push
# Kill the ssh-agent because we're done with deploying
eval $(ssh-agent -k)
echo "Done! Successfully deployed Javadocs to GitHub! :)"