DL-209: Update build script to build distributedlog website under `bookkeeper.apache.org/distributedlog`
*Problem*:
Currently `bookkeeper.apache.org/distributedlog` is using content at the root of branch `asf-site`.
`distributedlog.incubator.apache.org` is using content at `content` dir of branch `asf-site`.
The website build script should support both.
*Solution*:
- add `_config-apache.yml` for building website at baseurl `/distributedlog`
- update `website/build.sh` to build apache to build different configurations
- add a `publish-website.sh` to be able to publish website by CI
Also:
- add `_config-staging.yml` for building website at staging
- add a `staging-website.sh` to publish staging site.
Author: Sijie Guo <sijie@apache.org>
Reviewers: Jia Zhai <None>
This closes #136 from sijie/fix_production_url
diff --git a/README.md b/README.md
index 521e7cc..288351c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
![logo](/website/images/distributedlog_logo_m.png?raw=true "Apache DistributedLog logo")
-[![Build Status](https://travis-ci.org/apache/incubator-distributedlog.svg?branch=master)](https://travis-ci.org/apache/incubator-distributedlog)
+[![Build Status](https://api.travis-ci.org/apache/distributedlog.svg?branch=master)](https://travis-ci.org/apache/distributedlog)
[![Build Status](https://builds.apache.org/buildStatus/icon?job=distributedlog-nightly-build)](https://builds.apache.org/job/distributedlog-nightly-build/)
[![Coverage Status](https://coveralls.io/repos/github/apache/incubator-distributedlog/badge.svg?branch=master)](https://coveralls.io/github/apache/incubator-distributedlog?branch=master)
diff --git a/docs/_config-apache.yml b/docs/_config-apache.yml
new file mode 100644
index 0000000..bf395a3
--- /dev/null
+++ b/docs/_config-apache.yml
@@ -0,0 +1 @@
+baseurl: "/distributedlog/docs/latest"
diff --git a/docs/_config-staging.yml b/docs/_config-staging.yml
new file mode 100644
index 0000000..5edf570
--- /dev/null
+++ b/docs/_config-staging.yml
@@ -0,0 +1 @@
+baseurl: "/distributedlog-staging-site/docs/latest"
diff --git a/docs/_includes/header.html b/docs/_includes/header.html
index 14dc063..b1962db 100644
--- a/docs/_includes/header.html
+++ b/docs/_includes/header.html
@@ -2,7 +2,7 @@
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
- <a href="/" class="navbar-brand" >
+ <a href="/distributedlog" class="navbar-brand" >
<img alt="Brand" style="height: 28px" src="{{ "/images/distributedlog_logo_navbar.png" | prepend: site.baseurl }}">
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
diff --git a/pom.xml b/pom.xml
index 1493d4e..7b44cf7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,7 +142,7 @@
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<!-- Avoid for missing javadoc comments to be marked as errors -->
- <additionalparam>-Xdoclint:none</additionalparam>
+ <additionalparam>-Xdoclint:none -notimestamp</additionalparam>
<groups>
<group>
<title>Core Library</title>
diff --git a/website/_config-apache.yml b/website/_config-apache.yml
new file mode 100644
index 0000000..5746e2a
--- /dev/null
+++ b/website/_config-apache.yml
@@ -0,0 +1 @@
+baseurl: "/distributedlog"
diff --git a/website/_config-staging.yml b/website/_config-staging.yml
new file mode 100644
index 0000000..428e3c8
--- /dev/null
+++ b/website/_config-staging.yml
@@ -0,0 +1 @@
+baseurl: "/distributedlog-staging-site"
diff --git a/website/_config.yml b/website/_config.yml
index f9d4734..a0243ee 100644
--- a/website/_config.yml
+++ b/website/_config.yml
@@ -52,3 +52,6 @@
gems:
- jekyll-redirect-from
+
+exclude:
+ - scripts
diff --git a/website/_includes/head.html b/website/_includes/head.html
index 13dcd36..1f1fc61 100644
--- a/website/_includes/head.html
+++ b/website/_includes/head.html
@@ -10,8 +10,8 @@
<link rel="stylesheet" href="{{ "/css/theme.css" | prepend: site.baseurl }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="{{ "/js/bootstrap.min.js" | prepend: site.baseurl }}"></script>
- <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}" data-proofer-ignore>
- <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
+ <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url | replace:'distributedlog/distributedlog/','distributedlog/'}}" data-proofer-ignore>
+ <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url | replace:'distributedlog/distributedlog/','distributedlog/'}}">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
diff --git a/website/_includes/header.html b/website/_includes/header.html
index 681cae8..fcf62ef 100644
--- a/website/_includes/header.html
+++ b/website/_includes/header.html
@@ -1,7 +1,7 @@
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
- <a href="/" class="navbar-brand" >
+ <a href="/distributedlog" class="navbar-brand" >
<img alt="Brand" style="height: 28px" src="{{ "/images/distributedlog_logo_navbar.png" | prepend: site.baseurl }}">
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
@@ -85,7 +85,7 @@
<li><a href="{{ site.coding_guide_url }}">Coding Guide</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Guides</li>
- <li><a href="{{ site.baseurl }}/community/release_guide">Release Guide</a></li>
+ <li><a href="{{ site.baseurl }}/community/release-guide">Release Guide</a></li>
</ul>
</li>
<!-- Project -->
diff --git a/website/_posts/2016-09-19-kafka-vs-distributedlog.md b/website/_posts/2016-09-19-kafka-vs-distributedlog.md
index c8f8cec..66d57ab 100644
--- a/website/_posts/2016-09-19-kafka-vs-distributedlog.md
+++ b/website/_posts/2016-09-19-kafka-vs-distributedlog.md
@@ -5,6 +5,7 @@
categories: technical-review
redirect_from:
- /technical-review/2015/09/19/kafka-vs-distributedlog
+- /distributedlog/technical-review/2015/09/19/kafka-vs-distributedlog
authors:
- sijie
---
diff --git a/website/build.sh b/website/build.sh
index 1eb64ba..1ae21ae 100755
--- a/website/build.sh
+++ b/website/build.sh
@@ -40,26 +40,28 @@
fi
SERVE="FALSE"
-if [ $# -gt 2 ]; then
+if [ $# -gt 3 ]; then
SERVE="TRUE"
fi
+TMP_DEST_DIR=${DEST_DIR}/temp_content
+TMP_WEBSITE_DIR=${TMP_DEST_DIR}/website
+
rm -rf ${DEST_DIR}/content
+rm -rf ${TMP_DEST_DIR}
if [ ! -d "${DLOG_HOME}/website/docs" ]; then
mkdir ${DLOG_HOME}/website/docs
fi
-echo "Building the website to ${DEST_DIR}/content ..."
+echo "Building the website to ${TMP_WEBSITE_DIR} ..."
# build the website
cd ${DLOG_HOME}/website
-bundle exec jekyll build --destination ${DEST_DIR}/content --config _config.yml,${OVERRIDED_CONFIG}
+bundle exec jekyll build --destination ${TMP_WEBSITE_DIR} --config _config.yml,${OVERRIDED_CONFIG}
-echo "Built the website @ ${DEST_DIR}/content."
-
-
+echo "Built the website @ ${TMP_WEBSITE_DIR}."
# build the documents
@@ -70,16 +72,16 @@
echo "Building the documentation for version ${version} ..."
DOC_SRC_HOME="${DLOG_HOME}/website/docs/${version}"
- DOC_DEST_HOME="${DEST_DIR}/content/docs/${version}"
+ DOC_DEST_HOME="${TMP_DEST_DIR}/docs_${version}"
cd ${DOC_SRC_HOME}
bundle exec jekyll build --destination ${DOC_DEST_HOME} --config _config.yml,${OVERRIDED_CONFIG}
+ # create the api directory
+ mkdir -p ${DOC_DEST_HOME}/api/java
if [ "$version" == "latest" ]; then
cd ${DLOG_HOME}
- # create the api directory
- mkdir -p ${DEST_DIR}/content/docs/latest/api/java
# build the javadoc
mvn -DskipTests clean package javadoc:aggregate \
-Ddoctitle="Apache DistributedLog for Java, version ${version}" \
@@ -88,16 +90,15 @@
# copy the built javadoc
cp -r ${DLOG_HOME}/target/site/apidocs/* ${DOC_DEST_HOME}/api/java
else
- rm -r /tmp/distributedlog-${version}
- git clone https://gitbox.apache.org/repos/asf/distributedlog.git /tmp/distributedlog-${version}
+ rm -rf /tmp/distributedlog-${version}
+ git clone https://github.com/apache/distributedlog.git /tmp/distributedlog-${version}
cd /tmp/distributedlog-${version}
git checkout $tag
- # create the api directory
- mkdir -p ${DEST_DIR}/content/docs/${version}/api/java
# build the javadoc
mvn -DskipTests clean package javadoc:aggregate \
-Ddoctitle="Apache DistributedLog for Java, version ${version}" \
-Dwindowtitle="Apache DistributedLog for Java, version ${version}" \
+ -Dnotimestamp \
-Dmaven.javadoc.failOnError=false
# copy the built javadoc
cp -r /tmp/distributedlog-${version}/target/site/apidocs/* ${DOC_DEST_HOME}/api/java
@@ -108,10 +109,21 @@
# build the javadoc API
build_docs "latest"
-build_docs "0.4.0-incubating" "v0.4.0-incubating-RC4_2.11"
+build_docs "0.4.0-incubating" "v0.4.0-incubating_2.11"
+
+cp -r ${TMP_DEST_DIR}/website ${DEST_DIR}/content
+mkdir -p ${DEST_DIR}/content/docs
+[[ -d ${DEST_DIR}/content/docs/latest ]] && rm -r ${DEST_DIR}/content/docs/latest
+[[ -d ${DEST_DIR}/content/docs/0.4.0-incubating ]] && rm -r ${DEST_DIR}/content/docs/0.4.0-incubating
+cp -r ${TMP_DEST_DIR}/docs_latest ${DEST_DIR}/content/docs/latest
+cp -r ${TMP_DEST_DIR}/docs_0.4.0-incubating ${DEST_DIR}/content/docs/0.4.0-incubating
+
+cp -r ${TMP_DEST_DIR}/website ${DEST_DIR}/content
+mkdir -p ${DEST_DIR}/content/docs
+cp -r ${TMP_DEST_DIR}/docs_latest ${DEST_DIR}/content/docs/latest
+cp -r ${TMP_DEST_DIR}/docs_0.4.0-incubating ${DEST_DIR}/content/docs/0.4.0-incubating
if [[ "${SERVE}" == "TRUE" ]]; then
cd ${DLOG_HOME}/website
bundle exec jekyll serve --destination ${DEST_DIR}/content --config _config.yml,${OVERRIDED_CONFIG} --incremental
fi
-
diff --git a/website/community/community.md b/website/community/community.md
index e6351c9..63978ea 100644
--- a/website/community/community.md
+++ b/website/community/community.md
@@ -24,7 +24,7 @@
</thead>
<tr>
<td>
- <strong>distributedlog-user</strong>@bookkeeper.apache.org<br>
+ <strong>distributedlog-user</strong>@bookkeeper.apache.org<br>
<small>User related discussions</small>
</td>
<td class="text-center"><i class="fa fa-pencil-square-o"></i> <a href="mailto:distributedlog-user-subscribe@bookkeeper.apache.org">Subscribe</a></td>
@@ -79,7 +79,7 @@
### Main source repositories
-- **ASF gitbox**: [https://gitbox.apache.org/repos/asf/distributedlog.git](https://gitbox.apache.org/repos/asf/distributedlog.git)
-- **GitHub mirror**: [https://github.com/apache/distributedlog.git](https://github.com/apache/distributedlog.git)
+- **ASF gitbox**: [https://gitbox.apache.org/repos/asf/distributedlog.git](https://gitbox.apache.org/repos/asf/distributedlog.git)
+- **GitHub repo**: [https://github.com/apache/distributedlog.git](https://github.com/apache/distributedlog.git)
Note: We prefer to run distributedlog using Java 8.
diff --git a/website/docs/0.4.0-incubating/_config-apache.yml b/website/docs/0.4.0-incubating/_config-apache.yml
new file mode 100644
index 0000000..305c08f
--- /dev/null
+++ b/website/docs/0.4.0-incubating/_config-apache.yml
@@ -0,0 +1 @@
+baseurl: "/distributedlog/docs/0.4.0-incubating"
diff --git a/website/docs/0.4.0-incubating/_config-staging.yml b/website/docs/0.4.0-incubating/_config-staging.yml
new file mode 100644
index 0000000..c3648ea
--- /dev/null
+++ b/website/docs/0.4.0-incubating/_config-staging.yml
@@ -0,0 +1 @@
+baseurl: "/distributedlog-staging-site/docs/0.4.0-incubating"
diff --git a/website/docs/0.4.0-incubating/_includes/header.html b/website/docs/0.4.0-incubating/_includes/header.html
index 14dc063..b1962db 100644
--- a/website/docs/0.4.0-incubating/_includes/header.html
+++ b/website/docs/0.4.0-incubating/_includes/header.html
@@ -2,7 +2,7 @@
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
- <a href="/" class="navbar-brand" >
+ <a href="/distributedlog" class="navbar-brand" >
<img alt="Brand" style="height: 28px" src="{{ "/images/distributedlog_logo_navbar.png" | prepend: site.baseurl }}">
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
diff --git a/website/scripts/publish-website.sh b/website/scripts/publish-website.sh
new file mode 100755
index 0000000..2c0a442
--- /dev/null
+++ b/website/scripts/publish-website.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# NOTE: this is the script used by CI to push to apache. If you are looking for
+# staging the changes, try the `staging-website.sh` script.
+
+PROD_DIR=$1
+APACHE_DIR=$2
+TMP_DIR=/tmp/distributedlog-site-tmp
+ORIGIN_REPO=$(git remote show origin | grep 'Push URL' | awk -F// '{print $NF}')
+echo "ORIGIN_REPO: $ORIGIN_REPO"
+
+(
+ rm -rf $TMP_DIR
+ mkdir -p $TMP_DIR
+ cd $TMP_DIR
+
+ # clone the remote repo
+ git clone "https://$ORIGIN_REPO" .
+ git config user.name "Apache DistributedLog Site Updater"
+ git config user.email "distributedlog-dev@bookkeeper.apache.org"
+ git checkout asf-site
+ # copy the apache generated dir
+ # cp -r $PROD_DIR/content/* $TMP_DIR/content/
+ cp -r $APACHE_DIR/content/* $TMP_DIR/
+
+ git add -A .
+ git diff-index --quiet HEAD || (git commit -m "Updated site at revision $REVISION" && git push -q origin HEAD:asf-site)
+
+ rm -rf $TMP_DIR
+)
diff --git a/website/scripts/staging-website.sh b/website/scripts/staging-website.sh
new file mode 100755
index 0000000..46392e2
--- /dev/null
+++ b/website/scripts/staging-website.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+LOCAL_GENERATED_DIR=$1
+TMP_DIR=/tmp/distributedlog-site-tmp
+ORIGIN_REPO=$(git remote show origin | grep 'Push URL' | awk -F// '{print $NF}')
+echo "ORIGIN_REPO: $ORIGIN_REPO"
+STAGING_REPO=`echo $ORIGIN_REPO | sed -e 's/distributedlog\.git/distributedlog-staging-site.git/g'`
+echo "STAGING_REPO: $STAGING_REPO"
+echo "GENERATE SITE DIR: $LOCAL_GENERATED_DIR"
+
+(
+ rm -rf $TMP_DIR
+ mkdir $TMP_DIR
+
+ cd $TMP_DIR
+ # clone the remote repo
+ git clone "https://$STAGING_REPO" .
+ # if the remote is empty, we should create the `docs` directory
+ mkdir -p $TMP_DIR/docs
+ # copy the local generated dir
+ cp -r $LOCAL_GENERATED_DIR/content/* $TMP_DIR/docs/
+
+ git add -A .
+ git commit -m "Updated site at revision $REVISION"
+ git push -q origin HEAD:master
+
+ rm -rf $TMP_DIR
+)