Deploy to GitHub and PyPI on tags
MODIFY
.travis.yml
.travis.yml
language: python
-script:
- - ./_travis/run.sh
+sudo: false
+
before_install:
- env
- openssl version
- python -c "import ssl; print(ssl.OPENSSL_VERSION)"
+
+install:
+ - ./_travis/install.sh
+
+script:
+ - ./_travis/run.sh
+
after_success:
- ./_travis/upload_coverage.sh
+
cache:
directories:
- ${HOME}/.cache
-install:
- - ./_travis/install.sh
+
notifications:
email: false
+
env:
global:
- GAE_SDK_PATH=${HOME}/.cache/google_appengine
- PYTHONWARNINGS=always::DeprecationWarning
+
+ - PYPI_USERNAME=shazow
+ - secure: ... # PYPI_PASSWORD
+
matrix:
- TOXENV=flake8-py3
- TOXENV=gae
- TOXENV=docs
-# https://github.com/travis-ci/travis-ci/issues/4794
+
matrix:
include:
- python: 2.7
@@ -59,6 +71,50 @@ matrix:
- language: generic
os: osx
env: TOXENV=py37
+
+ # TODO: make these integration tests
+ - python: 2.7
+ env: DOWNSTREAM=requests
+
+ - python: 3.7
+ env: DOWNSTREAM=requests
+ dist: xenial
+ sudo: required
+
+ - python: 2.7
+ env: DOWNSTREAM=botocore
+
+ - python: 3.7
+ env: DOWNSTREAM=botocore
+ dist: xenial
+ sudo: required
+
+
allow_failures:
- python: pypy-5.4
-sudo: false
+
+deploy:
+ - provider: script
+ script: bash _travis/deploy.sh
+ skip_cleanup: true
+ on:
+ branch: master
+ repo: urllib3/urllib3
+ tags: true
+ python: 3.7
+
+ - provider: releases
+ api_key:
+ secure: ... # GitHub access token
+ name: "$TRAVIS_TAG"
+ body: "Release $TRAVIS_TAG"
+ draft: true
+ skip_cleanup: true
+ file_glob: true
+ file: dist/*
+ overwrite: true
+ on:
+ branch: master
+ repo: urllib3/urllib3
+ tags: true
+ python: 3.7

ADD
_travis/deploy.sh
+#!/bin/bash
+
+set -exo pipefail
+
+python3 -m pip install --upgrade twine
+python3 setup.py sdist bdist_wheel
+python3 -m twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD --skip-existing

ADD
_travis/downstream/botocore.sh
+#!/bin/bash
+
+set -exo pipefail
+
+case "${1}" in
+ install)
+ git clone --depth 1 https://github.com/boto/botocore
+ cd botocore
+ git rev-parse HEAD
+ python scripts/ci/install
+ ;;
+ run)
+ cd botocore
+ python scripts/ci/run-tests
+ ;;
+ *)
+ exit 1
+ ;;
+esac

ADD
_travis/downstream/requests.sh
+#!/bin/bash
+
+set -exo pipefail
+
+case "${1}" in
+ install)
+ git clone --depth 1 https://github.com/requests/requests
+ cd requests
+ git rev-parse HEAD
+ python -m pip install --upgrade pipenv
+ pipenv install --dev --skip-lock
+ ;;
+ run)
+ cd requests
+ pipenv run py.test -n 8 --boxed
+ ;;
+ *)
+ exit 1
+ ;;
+esac

MODIFY
_travis/install.sh
_travis/install.sh
#!/bin/bash
-set -e
-set -x
+set -exo pipefail
if [[ "$(uname -s)" == 'Darwin' ]]; then
case "${TOXENV}" in
@@ -22,12 +21,10 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
curl https://bootstrap.pypa.io/get-pip.py | sudo $PYTHON_EXE
$PYTHON_EXE -m pip install virtualenv
else
- pip install virtualenv
+ python -m pip install virtualenv
fi
-pip install tox
-
if [[ "${TOXENV}" == "gae" ]]; then
- pip install gcp-devrel-py-tools
+ python -m pip install gcp-devrel-py-tools
gcp-devrel-py-tools download-appengine-sdk "$(dirname ${GAE_SDK_PATH})"
fi

MODIFY
_travis/run.sh
_travis/run.sh
#!/bin/bash
-set -e
-set -x
+set -exo pipefail
if [[ "$(uname -s)" == "Darwin" && "$TOXENV" == "py27" ]]; then
export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin":$PATH
fi
+if [ -n "${TOXENV}" ]; then
+ python -m pip install tox
tox
+else
+ downstream_script="${TRAVIS_BUILD_DIR}/_travis/downstream/${DOWNSTREAM}.sh"
+ if [ ! -x "$downstream_script" ]; then
+ exit 1
+ fi
+ $downstream_script install
+ python -m pip install .
+ $downstream_script run
+fi

MODIFY
_travis/upload_coverage.sh
_travis/upload_coverage.sh
#!/bin/bash
-set -e
-set -x
+set -exo pipefail
source .tox/${TOXENV}/bin/activate
pip install codecov

MODIFY
docs/contributing.rst
docs/contributing.rst
@@ -65,9 +65,31 @@ suite::
Our test suite `runs continuously on Travis CI
<https://travis-ci.org/urllib3/urllib3>`_ with every pull request.
-
-Sponsorship & Project Grants
-----------------------------
+Releases
+--------
+
+A release candidate can be created by any contributor by creating a branch
+named ``release-x.x`` where ``x.x`` is the version of the proposed release.
+
+- Update ``CHANGES.rst`` and ``urllib3/__init__.py`` with the proper version number
+ and commit the changes to ``release-x.x``.
+- Open a pull request to merge the ``release-x.x`` branch into the ``master`` branch.
+- Integration tests are run against the release candidate on Travis. From here on all
+ the steps below will be handled by a maintainer so unless you receive review comments
+ you are done here.
+- Once the pull request is squash merged into master the merging maintainer the
+ pull request will tag the merge commit with the version number:
+
+ - ``git tag -a 1.24.1 [commit sha]``
+ - ``git push origin master --tags``
+
+- After the commit is tagged Travis will build the tagged commit and upload the sdist and wheel
+ to PyPI and create a draft release on GitHub for the tag. The merging maintainer will
+ ensure that the PyPI sdist and wheel are properly uploaded.
+- The merging maintainer will mark the draft release on GitHub as an approved release.
+
+Sponsorship
+-----------
.. |tideliftlogo| image:: https://nedbatchelder.com/pix/Tidelift_Logos_RGB_Tidelift_Shorthand_On-White_small.png
:width: 75

DELETE
release.sh
-#!/bin/bash
-# Cut a new release based on the latest CHANGES.rst entry.
-# Must be called from the `release` branch.
-
-VERSION_FILE="urllib3/__init__.py"
-CHANGES_FILE="CHANGES.rst"
-
-if [ "$(git rev-parse --abbrev-ref HEAD)" != "release" ]; then
- echo "Must be called from the release branch."
- exit 1
-fi
-
-# Merge master
-git merge master --no-commit
-git checkout master -- CHANGES.rst
-
-# Remove dev section and update version.
-sed -i '' '4,9d' CHANGES.rst
-version="$(grep -m1 -B1 -- '-----' "${CHANGES_FILE}" | head -n1 | cut -d' ' -f1)"
-perl -p -i -e "s/__version__.*/__version__ = '${version}'/" "${VERSION_FILE}"
-git diff
-
-# Confirm
-read -n1 -p "Good? [Y/n] " r
-if ! [[ $r =~ ^([yY]*)$ ]]; then
- echo "Stopped."
- exit 2
-fi
-
-# Prepare commit
-git commit -a -m "Merging new release version: ${version}"
-git tag ${version} -s -m "Release: ${version}"
-
-# Build package
-make clean
-python setup.py sdist bdist_wheel
-
-# TODO: Shove a unicorn in here, or something.
-
-echo "Release is ready. Publish it when ready:"
-echo "git push origin"
-echo "twine upload dist/*"

Deploy to GitHub and PyPI on tags (#1508)