diff --git a/.gitignore b/.gitignore
index 8648ec99ad4..1c31ea4d24c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ PluginVerifier
tmp
*TestMy.java
.*.swp
+gh-pages
diff --git a/build.xml b/build.xml
index 7ea61a95155..570d57556dc 100644
--- a/build.xml
+++ b/build.xml
@@ -131,6 +131,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/updatedoc.sh b/updatedoc.sh
new file mode 100755
index 00000000000..5a6fea56b1e
--- /dev/null
+++ b/updatedoc.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# generates the API docs and uploads them to github pages
+# for help on github pages see: http://pages.github.com/
+
+# TODO can we fail the build if the docs are not created?
+ant doc || exit $?
+
+echo "Cloning/pulling latest gh-pages branch"
+
+git clone -b gh-pages git@github.com:JetBrains/kotlin.git gh-pages
+cd gh-pages
+git pull || exit $?
+rm -rf apidoc/stdlib/*
+cp -r ../dist/apidoc/* apidoc
+git add apidoc || exit $?
+git commit -m "latest apidocs" || exit $?
+git push || exit $?
+
+echo "Updated github pages for apidocs"