Skip to content

Commit 8ead095

Browse files
committed
Merge pull request #139 from ajkannan/latest-webpage-via-travis
Creating a latest webpage generated after Travis runs
2 parents fa74584 + 8c4fd41 commit 8ead095

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/site/resources/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h2>Quickstart with Maven: Add gcloud to your pom.xml</h2>
6262
<pre>&lt;dependency&gt;
6363
&lt;groupId&gt;com.google.gcloud&lt;/groupId&gt;
6464
&lt;artifactId&gt;gcloud-java&lt;/artifactId&gt;
65-
&lt;version&gt;0.0.6&lt;/version&gt;
65+
&lt;version&gt;{{SITE_VERSION}}&lt;/version&gt;
6666
&lt;/dependency&gt;</pre>
6767
</div><!-- end of .col.col-right -->
6868
</div><!-- end of .container -->

utilities/after_success.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,30 @@ echo "Travis pull request: " ${TRAVIS_PULL_REQUEST}
88
echo "Travis JDK version: " ${TRAVIS_JDK_VERSION}
99
if [ "${TRAVIS_JDK_VERSION}" == "oraclejdk7" -a "${TRAVIS_BRANCH}" == "master" -a "${TRAVIS_PULL_REQUEST}" == "false" ]; then
1010
mvn cobertura:cobertura coveralls:report
11-
mvn site-deploy -DskipTests=true --settings=target/travis/settings.xml
1211
mvn deploy -DskipTests=true -Dgpg.skip=true --settings target/travis/settings.xml
12+
13+
# Deploy site if not a SNAPSHOT
14+
SITE_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)')
15+
if [ "${SITE_VERSION##*-}" != "SNAPSHOT" ]; then
16+
mvn site-deploy -DskipTests=true --settings=target/travis/settings.xml
17+
18+
# Update "latest" webpage
19+
git config --global user.name "travis-ci"
20+
git config --global user.email "[email protected]"
21+
git clone --branch gh-pages --single-branch https://github.com/GoogleCloudPlatform/gcloud-java/ tmp_gh-pages
22+
cd tmp_gh-pages
23+
mkdir -p site/latest/
24+
echo "<html><head><meta http-equiv=\"refresh\" content=\"0; URL='http://GoogleCloudPlatform.github.io/gcloud-java/site/${SITE_VERSION}/index.html'\" /></head><body></body></html>" > site/latest/index.html
25+
git add site/latest/index.html
26+
27+
# Update "Quickstart with Maven" block on landing page to reflect latest version
28+
sed -i "s/{{SITE_VERSION}}/$SITE_VERSION/g" site/${SITE_VERSION}/index.html
29+
git add site/${SITE_VERSION}/index.html
30+
31+
git commit -m "Update the redirect in 'latest/index.html' and the version in the 'Quickstart with Maven' landing page box to $SITE_VERSION"
32+
git config --global push.default simple
33+
git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/gcloud-java.git" > /dev/null 2>&1
34+
fi
1335
else
1436
echo "Not deploying artifacts. This is only done with non-pull-request commits to master branch with Oracle Java 7 builds."
1537
fi

0 commit comments

Comments
 (0)