Skip to content
Snippets Groups Projects
Commit c19adef3 authored by André Anjos's avatar André Anjos 💬
Browse files

Minor improvements to new CI infrastructure

parent 91376b3e
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
# Wed 21 Sep 2016 13:08:05 CEST
# Functions for coloring echo commands
red_echo() {
echo -e "\033[1;31m${@}\033[0m"
}
green_echo() {
echo -e "\033[1;32m${@}\033[0m"
}
if [ -z "${PYPIUSER}" ] || [ -z "${PYPIPASS}" ]; then
red_echo "PYPIUSER and/or PYPIPASS undefined - aborting...";
exit 1
fi
if [ -z "${CI_BUILD_TAG}" ]; then
red_echo "CI_BUILD_TAG undefined - can only work with tags, aborting...";
exit 1
fi
PYPISERVER=`[ -z "${PYPISERVER}" ] || https://pypi.python.org`
TESTSERVER=https://testpypi.python.org
cat <<EOT >> ~/.pypirc
[distutils]
index-servers =
production
staging
[production]
repository: ${PYPISERVER}
username: ${PYPIUSER}
password: ${PYPIPASS}
[staging]
repository: https://testpypi.python.org/
username: ${PYPIUSER}
password: ${PYPIPASS}
EOT
chmod 600 ~/.pypirc
setup() {
local cmd=python setup.py "${@}"
green_echo "[>>] Running ${cmd}..."
local status=$?
if [ ${status} != 0 ]; then
red_echo "Command \"${cmd}\" failed - aborting..."
rm -f ~/.pypirc
exit ${status}
fi
}
green_echo "[>>] Uploading first to ${TESTSERVER} on behalf of ${PYPIUSER}..."
setup check sdist --formats zip upload --repository staging
green_echo "[<<] Test finished, proceeding..."
# if that worked, uploads documentation to pythonhosted if any exists
if [ -d doc ]; then
green_echo "[>>] Uploading documentation on behalf of ${PYPIUSER}..."
setup upload_docs --upload-dir sphinx
green_echo "[<<] Documentation uploaded, proceeding..."
fi
# if that worked, uploads source package to the production index
green_echo "[>>] Uploading package to ${PYPISERVER} on behalf of ${PYPIUSER}..."
setup check sdist --formats zip upload --repository production
green_echo "[<<] Package deployed, goodbye."
# cleanup
rm -f ~/.pypirc
exit 0
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
source $(dirname ${0})/functions.sh source $(dirname ${0})/functions.sh
run_cmd rm -rf ~/.pypirc
check_env CONDA_PREFIX check_env CONDA_PREFIX
run_cmd rm -rf ${CONDA_PREFIX} run_cmd rm -rf ${CONDA_PREFIX}
run_cmd rm -rf ~/.pypirc
...@@ -25,6 +25,3 @@ fi ...@@ -25,6 +25,3 @@ fi
# if that worked, uploads source package to the production index # if that worked, uploads source package to the production index
log_info "Uploading package to ${PYPISERVER} on behalf of ${PYPIUSER}..." log_info "Uploading package to ${PYPISERVER} on behalf of ${PYPIUSER}..."
setup check sdist --formats zip upload --repository production setup check sdist --formats zip upload --repository production
# cleanup
run_cmd rm -f ~/.pypirc
...@@ -52,18 +52,8 @@ run_cmd() { ...@@ -52,18 +52,8 @@ run_cmd() {
# Runs setup.py # Runs setup.py
setup() { setup() {
check_env CONDA_PREFIX check_env PREFIX
local python=`pwd`/${CONDA_PREFIX}/bin/python run_cmd ${PREFIX}/bin/python setup.py ${@}
log_info "Running \"${@}\"..."
${python} setup.py ${@}
local status=$?
if [ ${status} != 0 ]; then
log_error "Command Failed \"${python} setup.py ${@}\""
log_info rm -f ~/.pypirc
exit ${status}
else
log_info "Finished comand \"${python} setup.py ${@}\""
fi
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment