Use 0.9.0 release as default sources (#147)

* Use 0.9.0 release as default sources

* Adjust gitignore for sources

* Allow to download release but use master as default

* Rename download to download-src

* Avoid bash-builtin

* Add release option to readme
diff --git a/.gitignore b/.gitignore
index 24ad037..3cdf0a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
-openwhisk-master
-openwhisk-master*
+openwhisk-src
 
 *.iml
 .idea
diff --git a/docker-compose/Makefile b/docker-compose/Makefile
index 2764e5a..ef9d116 100644
--- a/docker-compose/Makefile
+++ b/docker-compose/Makefile
@@ -18,7 +18,8 @@
 DOCKER_HOST_IP ?= $(shell echo ${DOCKER_HOST} | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" || echo ${LOCAL_IP})
 DOCKER_REGISTRY ?= ""
 DOCKER_IMAGE_PREFIX ?= openwhisk
-OPENWHISK_PROJECT_HOME ?= ./openwhisk-master
+OPENWHISK_VERSION ?= master
+OPENWHISK_PROJECT_HOME ?= ./openwhisk-src
 OPENWHISK_CATALOG_HOME ?= ./openwhisk-catalog
 WSK_CLI ?= $(OPENWHISK_PROJECT_HOME)/bin/wsk
 OPEN_WHISK_DB_PREFIX ?= local_
@@ -38,27 +39,32 @@
 #   2. then it starts all components using docker-compose
 #   3. it runs a sample hello-world function
 #   To stop and cleanup the environment use: make destroy
-quick-start: download download-cli docker_pull run quick-start-pause hello-world quick-start-info
+quick-start: download-src download-cli docker_pull run quick-start-pause hello-world quick-start-info
 
 add-catalog: download-catalog init-catalog
 
-.PHONY: download
-download:
-	rm -rf ./openwhisk-master*
-	if [ "$(OPENWHISK_PROJECT_HOME)" = "./openwhisk-master" ]; then \
-        echo "Downloading source tar ball...."; \
-	    curl -o ./openwhisk-master.tar.gz -L https://github.com/apache/incubator-openwhisk/archive/master.tar.gz; \
+.PHONY: download-src
+download-src:
+	if [ ! -d $(OPENWHISK_PROJECT_HOME) -o "$(OPENWHISK_VERSION)" = "master" ]; then \
+        echo "Downloading source tar ball $(OPENWHISK_VERSION)...."; \
+	    if [ "$(OPENWHISK_VERSION)" = "master" ]; then \
+	        rm -rf "$(OPENWHISK_PROJECT_HOME)"; \
+	        curl -o ./openwhisk-src.tar.gz -L https://github.com/apache/incubator-openwhisk/archive/master.tar.gz; \
+        elif [ "$(OPENWHISK_VERSION)" = "0.9.0" ]; then \
+	        curl -o ./openwhisk-src.tar.gz -L https://github.com/apache/incubator-openwhisk/archive/0.9.0-incubating.tar.gz; \
+        fi; \
         echo "Unpacking tarball."; \
-	    mkdir openwhisk-master; \
-	    tar -xf ./openwhisk-master.tar.gz --strip 1 -C openwhisk-master; \
+	    mkdir -p $(OPENWHISK_PROJECT_HOME); \
+	    tar -xf ./openwhisk-src.tar.gz --strip 1 -C $(OPENWHISK_PROJECT_HOME); \
+	    rm ./openwhisk-src.tar.gz; \
 	else \
-	     echo "Skipping downloading the code from git as OPENWHISK_PROJECT_HOME is not default:" $(OPENWHISK_PROJECT_HOME); \
+	     echo "Skipping downloading the code as OPENWHISK_PROJECT_HOME is set to " $(OPENWHISK_PROJECT_HOME); \
 	fi
 
 .PHONY: download-catalog
 download-catalog:
-	rm -rf ./openwhisk-catalog*
 	if [ "$(OPENWHISK_CATALOG_HOME)" = "./openwhisk-catalog" ]; then \
+	    rm -rf ./openwhisk-catalog* \
 	    curl -O ./openwhisk-catalog.tar.gz -L https://api.github.com/repos/apache/incubator-openwhisk-catalog/tarball/master > ./openwhisk-catalog.tar.gz; \
 	    mkdir openwhisk-catalog; \
 	    tar -xf ./openwhisk-catalog.tar.gz --strip 1 -C openwhisk-catalog; \
@@ -106,7 +112,7 @@
 
 download-cli:
 	echo "downloading the CLI tool ... "
-	if [ "$(OPENWHISK_PROJECT_HOME)" = "./openwhisk-master" ]; then \
+	if [ ! -e "$(WSK_CLI)" ]; then \
         if [ "$(UNAME_STR)" = "Darwin" ]; then \
           echo "downloading cli for mac" ; \
           curl -o $(OPENWHISK_PROJECT_HOME)/bin/wsk.zip -L https://github.com/apache/incubator-openwhisk-cli/releases/download/latest/OpenWhisk_CLI-latest-mac-amd64.zip ; \
@@ -119,7 +125,7 @@
             tar -xf wsk.tgz ; \
         fi; \
 	else \
-         echo "Skipping downloading the cli from git as OPENWHISK_PROJECT_HOME is not default:" $(OPENWHISK_PROJECT_HOME); \
+         echo "Skipping downloading the cli as OPENWHISK_PROJECT_HOME is set to " $(OPENWHISK_PROJECT_HOME); \
 	fi
 
 .PHONY: run
@@ -337,7 +343,7 @@
 	rm hello.js
 
 .PHONY: pull
-pull: download setup
+pull: download-src setup
 	docker-compose --project-name openwhisk pull
 
 # Optional package configuration stages. These commands will install and set up
diff --git a/docker-compose/README.md b/docker-compose/README.md
index c07ca14..d765ce2 100644
--- a/docker-compose/README.md
+++ b/docker-compose/README.md
@@ -42,12 +42,13 @@
 ```
 
 If `OPENWHISK_PROJECT_HOME` variable is set ( i.e. `OPENWHISK_PROJECT_HOME=/path/to/openwhisk make quick-start`)
-then the command skips downloading the `master` branch and uses instead the source code found in the `PROJECT_HOME` folder.
+then the command skips downloading the sources and uses instead the source code found in the `OPENWHISK_PROJECT_HOME` folder.
 This is useful for working with a local clone, making changes to the code, and run it with `docker-compose`.
 
 This is the set of environment variables that can be set:
 
 * `OPENWHISK_PROJECT_HOME` - a checkout of [openwhisk](https://github.com/apache/incubator-openwhisk)
+* `OPENWHISK_VERSION` - defaults to `master` but can be set to [releases](https://github.com/apache/incubator-openwhisk/releases) such as `0.9.0`
 * `OPENWHISK_CATALOG_HOME` - a checkout of [openwhisk-catalog](https://github.com/apache/incubator-openwhisk-catalog)
 * `WSK_CLI` - the directory where the [`wsk` command line tool](https://github.com/apache/incubator-openwhisk-cli) can be found
 * `DOCKER_IMAGE_PREFIX` - the prefix of the docker images used for actions. If you are building and testing checkouts of runtimes locally, then consider setting this to `whisk`.