#!/usr/bin/env bash

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

# Makes sure we activate the base environment if available
run_cmd source ${CONDA_ROOT}/etc/profile.d/conda.sh
run_cmd conda activate base
export_env PATH

if [ -z "${BOB_BUILD_NUMBER}" ]; then
  set_conda_channels ${VISIBILITY} ${CI_COMMIT_TAG}
  set_next_bob_build_number ${CONDA_CHANNELS[0]}
fi

# copy the recipe_append.yaml over before build
run_cmd cp ${SCRIPTS_DIR}/recipe_append.yaml conda/recipe_append.yaml

BLDOPT="--no-anaconda-upload"
BLDOPT="${BLDOPT} --variant-config-files ${SCRIPTS_DIR}/conda_build_config.yaml"
BLDOPT="${BLDOPT} --python=${PYTHON_VERSION}"
if [ -n "${BOB_TEST_ONLY}" ]; then
  BLDOPT="${BLDOPT} --test"
fi

run_cmd ${CONDA_ROOT}/bin/conda build ${BLDOPT} conda