This is an automated email from the ASF dual-hosted git repository.

houshengbo pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-release.git


The following commit(s) were added to refs/heads/master by this push:
     new 6109982  Add script to package the documents (#220)
6109982 is described below

commit 6109982bbb82d09860ff1de4902eea5e3b04a7d6
Author: violagao <[email protected]>
AuthorDate: Mon Jul 9 11:41:59 2018 -0400

    Add script to package the documents (#220)
    
    This PR adds another flag called UPDATE_DOC to determine if the commit
    is going to change the documents or not.
    
    Besides, it re-arranged the logic when a PR is merged into master.
    It separated the conditions based on the TRAVIS_EVENT_TYPE, so that
    pull requests and pushes can be more trackable.
---
 docs/package_artifacts.md                        | 10 +++++++-
 tools/config.json                                |  3 ++-
 tools/load_config.sh                             |  1 +
 tools/{package_source_code.sh => package_doc.sh} | 20 +--------------
 tools/package_source_code.sh                     |  5 ----
 tools/travis/package_project.sh                  | 31 ++++++++++++++++--------
 6 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/docs/package_artifacts.md b/docs/package_artifacts.md
index c9db792..1c101e0 100644
--- a/docs/package_artifacts.md
+++ b/docs/package_artifacts.md
@@ -41,5 +41,13 @@ After downloading the source code, we can run the following 
script under _tools_
 ```
 $ ./package_source_code.sh
 ```
-This script will create a source code package file of source code suffixed 
with tar.gz for each project, under 
<local_release_dir>/openwhisk_sources/openwhisk/openwhisk-\<version\>.
+This script will create a source code package file of source code suffixed 
with tar.gz for each project, under 
<local_release_dir>/openwhisk_sources/openwhisk/apache-openwhisk-\<version\>.
 The key version is defined in _config.json_.
+
+## Adding or updating the documents
+
+We can run the following script under _tools_ to add or update the documents 
for the current release:
+```
+$ ./package_doc.sh
+```
+This script will copy all the files under releases/<current version> into the 
designated directory, 
<local_release_dir>/openwhisk_sources/openwhisk/apache-openwhisk-\<version\>/doc/.
diff --git a/tools/config.json b/tools/config.json
index cfefb2d..84c8bd6 100644
--- a/tools/config.json
+++ b/tools/config.json
@@ -1,5 +1,6 @@
 {
-  "publish_stage": "true",
+  "publish_stage": "false",
+  "update_doc": "true",
   "stage_url": "https://dist.apache.org/repos/dist/dev/incubator/openwhisk";,
   "release_url": 
"https://dist.apache.org/repos/dist/release/incubator/openwhisk";,
   "versioning": {
diff --git a/tools/load_config.sh b/tools/load_config.sh
index 88eed58..b18b628 100755
--- a/tools/load_config.sh
+++ b/tools/load_config.sh
@@ -41,6 +41,7 @@ OPENWHISK_SVN="$OPENWHISK_RELEASE_DIR/openwhisk"
 OPENWHISK_PROJECT_NAME="apache-openwhisk"
 
 PUBLISH_STAGE=$(json_by_key "$CONFIG" "publish_stage")
+UPDATE_DOC=$(json_by_key "$CONFIG" "update_doc")
 repos=$(echo $(json_by_key "$CONFIG" "RepoList") | sed 's/[][]//g')
 STAGE_URL=$(json_by_key "$CONFIG" "stage_url")
 RELEASE_URL=$(json_by_key "$CONFIG" "release_url")
diff --git a/tools/package_source_code.sh b/tools/package_doc.sh
similarity index 52%
copy from tools/package_source_code.sh
copy to tools/package_doc.sh
index 33ce04b..f14f129 100755
--- a/tools/package_source_code.sh
+++ b/tools/package_doc.sh
@@ -18,31 +18,13 @@
 
 set -e
 
-echo "Package the artifacts."
+echo "Package the documents."
 
 SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
 source "$SCRIPTDIR/load_config.sh" $1 $2 $3
 
 mkdir -p $CURRENT_VERSION_DIR
 
-# Clean up all the source code by excluding unnecessary files and folders
-# Remove all the hidden files and folder
-# Remove bin and build folders
-mkdir -p $OPENWHISK_CLEANED_SOURCE_DIR
-rm -rf $OPENWHISK_CLEANED_SOURCE_DIR/*
-rsync -rtp --exclude gradle/wrapper/gradle-\*.jar --exclude .bin --exclude 
.jshintrc --exclude .pydevproject --exclude .rat-excludes --exclude .git\* 
--exclude .travis.yml --exclude build --exclude specification/archive --exclude 
specification/diagrams --exclude tests $OPENWHISK_SOURCE_DIR/. 
$OPENWHISK_CLEANED_SOURCE_DIR
-
-for repo in $(echo $repos | sed "s/,/ /g")
-do
-    repo_name=$(echo "$repo" | sed -e 's/^"//' -e 's/"$//')
-    project_name="incubator-$repo_name"
-    rm -rf $OPENWHISK_CLEANED_SOURCE_DIR/$project_name/.git
-    cd $OPENWHISK_CLEANED_SOURCE_DIR
-    # Rename the directory by adding the version number
-    mv $project_name $project_name-$version
-    tar czf ${CURRENT_VERSION_DIR}/${repo_name}-${version}-sources.tar.gz 
$project_name-$version
-done
-
 # Copy the documents for the current release into the $CURRENT_VERSION_DIR 
directory
 PARENTDIR="$(dirname "$SCRIPTDIR")"
 mkdir -p ${CURRENT_VERSION_DIR}/doc
diff --git a/tools/package_source_code.sh b/tools/package_source_code.sh
index 33ce04b..0f36027 100755
--- a/tools/package_source_code.sh
+++ b/tools/package_source_code.sh
@@ -42,8 +42,3 @@ do
     mv $project_name $project_name-$version
     tar czf ${CURRENT_VERSION_DIR}/${repo_name}-${version}-sources.tar.gz 
$project_name-$version
 done
-
-# Copy the documents for the current release into the $CURRENT_VERSION_DIR 
directory
-PARENTDIR="$(dirname "$SCRIPTDIR")"
-mkdir -p ${CURRENT_VERSION_DIR}/doc
-cp $PARENTDIR/releases/$version/* ${CURRENT_VERSION_DIR}/doc/
diff --git a/tools/travis/package_project.sh b/tools/travis/package_project.sh
index b6ac0f6..5323807 100755
--- a/tools/travis/package_project.sh
+++ b/tools/travis/package_project.sh
@@ -31,21 +31,32 @@ if [ ! -z "$TRAVIS_TAG" ] ; then
     release_version=$TRAVIS_TAG
     source "$PARENTDIR/load_config.sh" "$SVN_USERNAME" "$SVN_PASSWORD" 
"$PARENTDIR" "$release_version"
     "$PARENTDIR/move_stage_to_release.sh" "$SVN_USERNAME" "$SVN_PASSWORD"
-else
+elif [ "$TRAVIS_EVENT_TYPE" == "push" ] ; then
+    # For the Travis builds based on PRs, we only pick the necessary steps 
based on the flags PUBLISH_STAGE and UPDATE_DOC configured in config.json.
     source "$PARENTDIR/load_config.sh" "$SVN_USERNAME" "$SVN_PASSWORD" 
"$PARENTDIR"
     "$PARENTDIR/download_source_code.sh"
-    if [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$PUBLISH_STAGE" == "true" ] ; 
then
-        "$PARENTDIR/checkout_svn.sh" "$SVN_USERNAME" "$SVN_PASSWORD"
-    fi
-
-    "$PARENTDIR/package_source_code.sh"
-    "$PARENTDIR/package_binaries.sh"
-
-    if [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$PUBLISH_STAGE" == "true" ] ; 
then
+    "$PARENTDIR/checkout_svn.sh" "$SVN_USERNAME" "$SVN_PASSWORD"
+    if [ "$PUBLISH_STAGE" == "true" ] ; then
+        "$PARENTDIR/package_source_code.sh"
+        if [ "$UPDATE_DOC" == "true" ] ; then
+            "$PARENTDIR/package_doc.sh"
+        fi
+        "$PARENTDIR/package_binaries.sh"
         "$CURRENTDIR/import_pgp_key.sh"
         "$PARENTDIR/sign_artifacts.sh"
         "$PARENTDIR/upload_artifacts.sh" "$SVN_USERNAME" "$SVN_PASSWORD"
+        "$PARENTDIR/verify_source_code.sh"
+    elif [ "$UPDATE_DOC" == "true" ] ; then
+        "$PARENTDIR/package_doc.sh"
+        "$PARENTDIR/upload_artifacts.sh" "$SVN_USERNAME" "$SVN_PASSWORD"
+        "$PARENTDIR/verify_source_code.sh"
     fi
-
+elif [ "$TRAVIS_EVENT_TYPE" == "pull_request" ] ; then
+    # For the Travis builds based on PRs, we need to verify all the steps, 
expect importing credentials, and uploading the artifacts.
+    source "$PARENTDIR/load_config.sh" "$SVN_USERNAME" "$SVN_PASSWORD" 
"$PARENTDIR"
+    "$PARENTDIR/download_source_code.sh"
+    "$PARENTDIR/package_source_code.sh"
+    "$PARENTDIR/package_doc.sh"
+    "$PARENTDIR/package_binaries.sh"
     "$PARENTDIR/verify_source_code.sh"
 fi

Reply via email to