diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index c42ee4d03eea8f5065df971e1c6916fc9fe114e7..979ef6433a0afd54f1a7e4a686982f232ea234e3 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -371,3 +371,9 @@ LANG="en_US.UTF-8"
 LC_ALL="${LANG}"
 export_env LANG
 export_env LC_ALL
+
+# ask conda to cache and build in the project directory
+CONDA_ENVS_PATH="conda-env"
+CONDA_BLD_PATH="conda-env"
+export_env CONDA_ENVS_PATH
+export_env CONDA_BLD_PATH
diff --git a/templates/ci.yml b/templates/ci.yml
index b94bdc976c54dfd368a7f23a5760d2460ece6168..f4823ec0845456bcecd16f8003bd257e57e34a73 100644
--- a/templates/ci.yml
+++ b/templates/ci.yml
@@ -13,9 +13,12 @@ stages:
 .build_template: &build_job
   stage: build
   before_script:
-    - git clean -ffdx
+    - export PATH=/opt/miniconda/bin:$PATH
     - mkdir _ci
-    - curl --silent "https://gitlab.idiap.ch/bob/bob.admin/raw/condapackage/gitlab/install.sh" > _ci/install.sh
+    - curl https://curl.haxx.se/ca/cacert.pem > _ci/cacert.pem
+    - export CURL_CA_BUNDLE=`pwd`/_ci/cacert.pem
+    - export SSL_CERT_FILE=`pwd`/_ci/cacert.pem
+    - curl "https://gitlab.idiap.ch/bob/bob.admin/raw/condapackage/gitlab/install.sh" > _ci/install.sh
     - chmod 755 _ci/install.sh
     - ./_ci/install.sh _ci condapackage
   script:
@@ -25,74 +28,70 @@ stages:
     paths:
       - conda-env/.pkgs/*.tar.bz2
       - conda-env/.pkgs/urls.txt
-      - conda-env/src_cache
+
+.build_linux_template: &linux_build_job
+  <<: *build_job
+  artifacts:
+    expire_in: 1 week
+    paths:
+      - _ci/
+      - dist/
+      - conda-env/linux-64/*.tar.bz2
+  tags:
+    - docker
+  image: continuumio/conda_builder_linux
+
+.build_macosx_template: &macosx_build_job
+  <<: *build_job
   artifacts:
     expire_in: 1 week
     paths:
       - _ci/
       - dist/
-      - conda-env/$OS_SLUG/
+      - conda-env/osx-64/*.tar.bz2
+  tags:
+    - conda-macosx
 
 
 build_linux_27:
-  <<: *build_job
+  <<: *linux_build_job
   variables:
     PYTHON_VERSION: "2.7"
-  tags:
-    - docker
-  image: continuumio/conda_builder_linux
 
 build_linux_35:
-  <<: *build_job
+  <<: *linux_build_job
   variables:
     PYTHON_VERSION: "3.5"
-  tags:
-    - docker
-  image: continuumio/conda_builder_linux
 
 build_linux_36:
-  <<: *build_job
+  <<: *linux_build_job
   variables:
     PYTHON_VERSION: "3.6"
     BUILD_EGG: "true"
-  tags:
-    - docker
-  image: continuumio/conda_builder_linux
 
 build_macosx_27:
-  <<: *build_job
+  <<: *macosx_build_job
   variables:
     PYTHON_VERSION: "2.7"
-  tags:
-    - conda-macosx
 
 build_macosx_35:
-  <<: *build_job
+  <<: *macosx_build_job
   variables:
     PYTHON_VERSION: "3.5"
-  tags:
-    - conda-macosx
 
 build_macosx_36:
-  <<: *build_job
+  <<: *macosx_build_job
   variables:
     PYTHON_VERSION: "3.6"
-  tags:
-    - conda-macosx
 
 
 # Deploy targets
-deploy_beta:
+.deploy_template: &deploy_job
   stage: deploy
-  environment: beta
-  only:
-    - master
-    - condapackage
-    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
   before_script:
-    - ./_ci/install.sh _ci #updates
+    - ./_ci/install.sh _ci condapackage
   script:
-    - ./_ci/deploy_beta.sh
+    - ./_ci/deploy.sh
   dependencies:
     - build_linux_27
     - build_linux_35
@@ -103,6 +102,21 @@ deploy_beta:
   tags:
     - deployer
 
+deploy_beta:
+  <<: *deploy_job
+  environment: beta
+  only:
+    - master
+    - condapackage
+
+deploy_stable:
+  <<: *deploy_job
+  environment: stable
+  only:
+    - /^v\d+\.\d+\.\d+([abc]\d*)?$/  # PEP-440 compliant version (tags)
+  except:
+    - branches
+
 
 pypi:
   stage: pypi
@@ -112,7 +126,7 @@ pypi:
   except:
     - branches
   before_script:
-    - ./_ci/install.sh _ci #updates
+    - ./_ci/install.sh _ci condapackage
   script:
     - ./_ci/pypi.sh
   dependencies: