Skip to content
Snippets Groups Projects
Commit 1007a84d authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Add deploy to PyPI step

parent 510dbda3
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
green_echo "[>>] Uploading documentation on behalf of ${PYPIUSER}..."
setup upload_docs --upload-dir sphinx
green_echo "[<<] Documentation uploaded, proceeding..."
# 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
......@@ -14,6 +14,7 @@ stages:
- test
- docs
- wheels
- deploy
# Global variables
......@@ -88,9 +89,10 @@ variables:
# architectures (Linux and Mac OSX 64-bit)
.wheels_template: &wheels_job
stage: wheels
environment: intranet
only:
- master
- tags
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant version (tags)
before_script:
- curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/ci/wheels.sh > wheels.sh
- chmod 755 wheels.sh
......@@ -102,6 +104,7 @@ variables:
# Only one real job needs to do this
.docs_template: &docs_job
stage: docs
environment: intranet
only:
- master
before_script:
......@@ -111,6 +114,29 @@ variables:
- ./docs.sh
# Template for the pypi stage - re-install from uploaded wheels
# Needs to run on a single architecture
.deploy_template: &deploy_job
stage: deploy
environment: pypi
only:
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant version (tags)
except:
- branches
before_script:
- ./bootstrap.sh ${CONDA_FOLDER} ${PYTHON_VER} ${CONDA_PREFIX}
- source ${CONDA_FOLDER}/bin/activate ${CONDA_PREFIX}
- pip install --use-wheel --no-index --pre dist/*.whl
- curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/ci/pypi.sh > pypi.sh
- chmod 755 pypi.sh
script:
- source ${CONDA_FOLDER}/bin/activate ${CONDA_PREFIX}
- ./pypi.sh
after_script:
- rm -rf ~/.pypirc
- rm -rf ${CONDA_PREFIX}
# 2) Package specific instructions (you may tune this if needed)
# --------------------------------------------------------------
......@@ -164,7 +190,7 @@ wheels_linux_34:
- conda-linux
# Linux + Python 3.5: Builds and tests
# Linux + Python 3.5: Builds, tests and deploys
build_linux_35:
<<: *linux_build_job
variables: &linux_35_build_variables
......@@ -195,6 +221,13 @@ docs_linux_35:
tags:
- conda-linux
deploy_linux_35:
<<: *deploy_job
dependencies:
- build_linux_35
tags:
- conda-linux
# Mac OSX + Python 2.7: Builds, tests and uploads the wheel
build_macosx_27:
......
......@@ -14,6 +14,7 @@ stages:
- test
- docs
- wheels
- deploy
# Global variables
......@@ -89,22 +90,52 @@ variables:
# architectures (Linux and Mac OSX 64-bit)
.wheels_template: &wheels_job
stage: wheels
environment: intranet
only:
- master
- tags
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant version (tags)
before_script:
- curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/ci/docs.sh > docs.sh
- chmod 755 docs.sh
- curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/ci/wheels.sh > wheels.sh
- chmod 755 wheels.sh
script:
- ./docs.sh
- ./wheels.sh
# Template for (latest) documentation upload stage
# Only one real job needs to do this
.docs_template: &docs_job
stage: docs
environment: intranet
only:
- master
before_script:
- curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/ci/docs.sh > docs.sh
- chmod 755 docs.sh
script:
- ./docs.sh
# Template for the pypi stage - re-install from uploaded wheels
# Needs to run on a single architecture
.deploy_template: &deploy_job
stage: deploy
environment: pypi
only:
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant version (tags)
except:
- branches
before_script:
- ./bootstrap.sh ${CONDA_FOLDER} ${PYTHON_VER} ${CONDA_PREFIX}
- source ${CONDA_FOLDER}/bin/activate ${CONDA_PREFIX}
- pip install --use-wheel --no-index --pre dist/*.whl
- curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/ci/pypi.sh > pypi.sh
- chmod 755 pypi.sh
script:
- source ${CONDA_FOLDER}/bin/activate ${CONDA_PREFIX}
- ./pypi.sh
after_script:
- rm -rf ~/.pypirc
- rm -rf ${CONDA_PREFIX}
# 2) Package specific instructions (you may tune this if needed)
......@@ -155,7 +186,7 @@ test_linux_34:
- conda-linux
# Linux + Python 3.5: Builds, tests, uploads wheel
# Linux + Python 3.5: Builds, tests, uploads wheel and deploys
build_linux_35:
<<: *linux_build_job
variables: &linux_35_build_variables
......@@ -187,6 +218,13 @@ docs_linux_35:
tags:
- conda-linux
deploy_linux_35:
<<: *deploy_job
dependencies:
- build_linux_35
tags:
- conda-linux
# Mac OSX + Python 2.7: Builds and tests
build_macosx_27:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment