Upload binaries to bintray (#528)

diff --git a/.bintray.json b/.bintray.json
new file mode 100644
index 0000000..10c09b4
--- /dev/null
+++ b/.bintray.json
@@ -0,0 +1,21 @@
+{
+    "package": {
+        "name": "${TRAVIS_OS_NAME}-bin",
+        "repo": "brotli",
+        "subject": "eustas"
+    },
+
+    "version": {
+        "name": "r${GIT_REVISION}",
+        "desc": "Snapshot Artifacts",
+        "released": "${RELEASE_DATE}",
+        "gpgSign": false
+    },
+
+    "files": [
+        {"includePattern": "bazel-bin/(libbrotli.*)", "uploadPattern": "$1"},
+        {"includePattern": "bazel-bin/bro", "uploadPattern": "bro"},
+    ],
+
+    "publish": true
+}
\ No newline at end of file
diff --git a/.travis.sh b/.travis.sh
index 2ddf6e1..496cdef 100755
--- a/.travis.sh
+++ b/.travis.sh
@@ -71,7 +71,7 @@
 		mvn install && cd integration && mvn verify
 		;;
 	    "bazel")
-		bazel test ...:all
+		bazel test -c opt ...:all
 		;;
 	esac
 	;;
@@ -87,4 +87,13 @@
 		;;
 	esac
 	;;
+    "before_deploy")
+	case "${BUILD_SYSTEM}" in
+	    "bazel")
+		export GIT_REVISION=`git rev-list --count @`
+		export RELEASE_DATE=`date +%Y-%m-%d`
+		perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' .bintray.json
+		;;
+	esac
+	;;
 esac
diff --git a/.travis.yml b/.travis.yml
index f87946d..bdc4300 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -260,9 +260,10 @@
 
 before_deploy:
 - if [ "${BUILD_SYSTEM}" = "python" ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then export WHEELS=$(ls ./dist/*.whl); fi
+- ./.travis.sh before_deploy
 
 deploy:
-  provider: releases
+- provider: releases
   api_key:
     secure: YcCBi6W/w4dtKCa59Wfm8L5lGWvK7KxaFNDr3yh1Hz5aStXXf758pEMHGewnlbfbwuj5a3SjBb1nLp1M69OQJfxm442uXBaBKo52PM9PPbD7NjvbNIso73pqcSODXQXKuZxDFpEhfuDTVq3hUkUqiwhChWhrFucJsSL51i7qSss=
   file: "${WHEELS}"
@@ -271,3 +272,12 @@
     repo: "google/brotli"
     tags: true
     condition: "${BUILD_SYSTEM} = python && ${TRAVIS_OS_NAME} = osx"
+- provider: bintray
+  file: ".bintray.json"
+  user: "eustas"
+  key:
+    secure: "Kbam/lTAdz72fZivbs6riJT+Y4PbuKP7r6t5PAWxJxAAykjwnYTRe3zF472g9HCE14KYMsdB+KSYSgg6TGJnqGC9gL9xhhGU9U/WmA+vbMWS/MSnMWpK9IRpp77pM2i2NKZD4v33JuEwKFCBJP3Vj6QQ5Qd1NKdobuXJyznhgnw="
+  on:
+    condition: "${BUILD_SYSTEM} = bazel"
+  skip_cleanup: true
+  dry-run: true