From 338e01c75d058952af5e941b9b4279e14f31a676 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Wed, 8 May 2019 09:14:03 +0200
Subject: [PATCH] test upload

@tonigi
---
 .travis.yml               |  2 ++
 conda/Makefile            |  3 +++
 conda/run-conda-build.sh  | 21 ---------------------
 conda/run-conda-upload.sh | 26 ++++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 21 deletions(-)
 create mode 100644 conda/run-conda-upload.sh

diff --git a/.travis.yml b/.travis.yml
index 44baae004..e7f7503ec 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -263,3 +263,5 @@ after_success:
   - if test "$MAKEDOC" == yes ; then ./.travis/push doc ; fi 
   - if test "$MAKECOVERAGE" == yes ; then ./.travis/push coverage ; fi 
   - if test "$MAKECOVERAGE" == yes ; then bash <(curl -s https://codecov.io/bash) > /dev/null ; fi
+# upload conda package
+  - if test -n "$PLUMED_CONDA" && test -n "$TRAVIS_TAG" ; then make -C conda upload ; fi
diff --git a/conda/Makefile b/conda/Makefile
index 021565a3f..5d070a1f6 100644
--- a/conda/Makefile
+++ b/conda/Makefile
@@ -8,6 +8,9 @@ all: build
 build:
 	bash run-conda-build.sh
 
+upload:
+	bash run-conda-upload.sh
+
 
 
 # https://conda.io/docs/user-guide/tasks/use-conda-with-travis-ci.html
diff --git a/conda/run-conda-build.sh b/conda/run-conda-build.sh
index 55de293e8..98a06d34d 100644
--- a/conda/run-conda-build.sh
+++ b/conda/run-conda-build.sh
@@ -26,24 +26,3 @@ conda-build recipe
 ls -l $CONDA_HOME/conda-bld/
 ls -l $CONDA_HOME/conda-bld/$TRAVIS_OS_NAME-64
 
-
-# And now upload if desired
-# conda upload $CONDA_HOME/conda-bld/linux-64/*.tar.bz2
-
-# https://gist.github.com/zshaheen/fe76d1507839ed6fbfbccef6b9c13ed9
-
-# https://conda.io/docs/user-guide/tasks/use-conda-with-travis-ci.html
-
-
-# One could play with this, but perhaps best not to spam the channel repository
-export VERSION=`date +%Y.%m.%d`
-
-# Disabled because it fails
-if [[ -n "$CONDA_UPLOAD_TOKEN" ]]; then
-    USER=plumed  # the conda channel
-    anaconda -t $CONDA_UPLOAD_TOKEN upload -u $USER -l testing \
-	     $CONDA_HOME/conda-bld/$TRAVIS_OS_NAME-64/plumed*.tar.bz2 --force
-fi
-
-
-
diff --git a/conda/run-conda-upload.sh b/conda/run-conda-upload.sh
new file mode 100644
index 000000000..03a3a2340
--- /dev/null
+++ b/conda/run-conda-upload.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Anywhere but outside of the repository
+export CONDA_HOME=/var/tmp/miniconda
+
+if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+    csys=Linux
+elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
+    csys=MacOSX
+else
+    echo "Unsupported system $TRAVIS_OS_NAME"
+    exit 1
+fi
+    
+export PATH="$CONDA_HOME/bin:$PATH"
+export VERSION=$TRAVIS_TAG
+
+# Disabled because it fails
+if [[ -n "$CONDA_UPLOAD_TOKEN" ]]; then
+    USER=plumed  # the conda channel
+    anaconda -t $CONDA_UPLOAD_TOKEN upload -u $USER -l testing \
+	     $CONDA_HOME/conda-bld/$TRAVIS_OS_NAME-64/plumed*.tar.bz2 --force
+fi
+
+
+
-- 
GitLab