#!/usr/bin/env bash
# Thu 22 Sep 2016 13:59:03 CEST

source $(dirname ${0})/functions.sh

lock_pypirc

setup_deploy register --repository staging
setup_deploy check sdist --formats zip upload --repository staging

# if that worked, uploads source package to the production index
log_info "Uploading package to ${PYPISERVER} on behalf of ${PYPIUSER}..."
setup_deploy register --repository production
setup_deploy check sdist --formats zip upload --repository production

# if that worked, uploads documentation to pythonhosted if any exists
if [ -d sphinx ]; then
  log_info "Uploading documentation to ${PYPISERVER} on behalf of ${PYPIUSER}..."
  setup_deploy upload_docs --upload-dir sphinx --repository production
fi

unlock_pypirc

condaforge_packages=("bob" \
"bob.extension" \
"bob.blitz" \
"bob.core" \
"bob.ip.draw" \
"bob.io.base" \
"bob.sp" \
"bob.math" \
"bob.ap" \
"bob.measure" \
"bob.db.base" \
"bob.io.image" \
"bob.io.video" \
"bob.io.matlab" \
"bob.ip.base" \
"bob.ip.color" \
"bob.ip.gabor" \
"bob.learn.activation" \
"bob.learn.libsvm" \
"bob.learn.boosting" \
"bob.io.audio" \
"bob.learn.linear" \
"bob.learn.mlp" \
"bob.db.wine" \
"bob.db.mnist" \
"bob.db.atnt" \
"bob.ip.flandmark" \
"bob.ip.facedetect" \
"bob.ip.optflow.hornschunck" \
"bob.ip.optflow.liu" \
"bob.learn.em" \
"bob.db.iris")

if contains_element ${CI_PROJECT_NAME}  "${condaforge_packages[@]}"; then
  run_cmd ${CONDA_FOLDER}/bin/python _ci/update_feedstock.py ${CI_PROJECT_NAME}
fi
