From 056bd7d967e55437e54c39a26c50607ea153415a Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 11 Sep 2018 12:09:50 +0200 Subject: [PATCH] [travis] use twine to upload to PyPI --- .travis.yml | 21 +++------------------ .travis/after_success.sh | 5 +++++ .travis/before_deploy.sh | 15 --------------- tox.ini | 12 +++++++++++- 4 files changed, 19 insertions(+), 34 deletions(-) delete mode 100755 .travis/before_deploy.sh diff --git a/.travis.yml b/.travis.yml index dcaed5e66..a7ea40ee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,10 @@ sudo: false language: python python: 3.5 -# empty "env:" is needed for 'allow_failures' -# https://docs.travis-ci.com/user/customizing-the-build/#Rows-that-are-Allowed-to-Fail env: + global: + - TWINE_USERNAME="anthrotype" + - secure: PJuCmlDuwnojiw3QuDhfNAaU4f/yeJcEcRzJAudA66bwZK7hvxV7Tiy9A17Bm6yO0HbJmmyjsIr8h2e7/PyY6QCaV8RqcMDkQ0UraU16pRsihp0giVXJoWscj2sCP4cNDOBVwSaGAX8yZ2OONc5srESywghzcy8xmgw6O+XFqx4= matrix: fast_finish: true @@ -73,9 +74,6 @@ script: after_success: - ./.travis/after_success.sh -before_deploy: - - ./.travis/before_deploy.sh - notifications: irc: "irc.freenode.org##fonts" email: fonttools-dev@googlegroups.com @@ -93,16 +91,3 @@ deploy: repo: fonttools/fonttools all_branches: true condition: "$BUILD_DIST == true" - # deploy to PyPI on tags - - provider: pypi - server: https://upload.pypi.org/legacy/ - user: anthrotype - password: - secure: DxAf1E0u4Xxe3+R9flkz69g84pfEQF2knDmKhZVzCJBbz9DUjuQlAWGZoAbn9kZIW0bq3yNIihVP5fjxgs0zKO7M4OCVRisVAgZDAZzsRo7awX9dBsyaTGt9WXvzVKCFPcehKI3lZ/fuPvovY+Dl4c91F5qfkh0pY6OKy9uDj3k= - skip_cleanup: true - distributions: pass - on: - tags: true - repo: fonttools/fonttools - all_branches: true - condition: "$BUILD_DIST == true" diff --git a/.travis/after_success.sh b/.travis/after_success.sh index d113fe7b6..07bcab5ec 100755 --- a/.travis/after_success.sh +++ b/.travis/after_success.sh @@ -9,3 +9,8 @@ fi # upload coverage data to Codecov.io [[ ${TOXENV} == *"-cov"* ]] && tox -e codecov + +# if tagged commit, create distribution packages and deploy to PyPI +if [ -n "$TRAVIS_TAG" ] && [ "$TRAVIS_REPO_SLUG" == "fonttools/fonttools" ] && [ "$BUILD_DIST" == true ]; then + tox -e pypi +fi diff --git a/.travis/before_deploy.sh b/.travis/before_deploy.sh deleted file mode 100755 index 1ded8f0f9..000000000 --- a/.travis/before_deploy.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e -set -x - -# build sdist and wheel distribution packages in ./dist folder. -# Travis runs the `before_deploy` stage before each deployment, but -# we only want to build them once, as we want to use the same -# files for both Github and PyPI -if $(ls ./dist/fonttools*.zip > /dev/null 2>&1) && \ - $(ls ./dist/fonttools*.whl > /dev/null 2>&1); then - echo "Distribution packages already exists; skipping" -else - tox -e bdist -fi diff --git a/tox.ini b/tox.ini index 6f23ec408..f452c986d 100644 --- a/tox.ini +++ b/tox.ini @@ -52,9 +52,19 @@ commands = # check metadata and rst long_description python setup.py check --restructuredtext --strict # clean up build/ and dist/ folders - rm -rf {toxinidir}/dist + python -c 'import shutil; shutil.rmtree("dist", ignore_errors=True)' python setup.py clean --all # build sdist python setup.py sdist --dist-dir {toxinidir}/dist # build wheel from sdist pip wheel -v --no-deps --no-index --wheel-dir {toxinidir}/dist --find-links {toxinidir}/dist fonttools + +[testenv:pypi] +deps = + {[testenv:bdist]deps} + twine +skip_install = true +passenv = TWINE_USERNAME TWINE_PASSWORD +commands = + {[testenv:bdist]commands} + twine upload dist/*.whl dist/*.zip