From ca7ffcc9febff40e6ac4fa636eba9f8b2bee3c0d Mon Sep 17 00:00:00 2001 From: New Date: Thu, 2 May 2019 01:26:00 +0800 Subject: [PATCH] fix(pypi): get ci env --- .travis.yml | 1 + setup.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 987289d..1ca18b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ deploy: - provider: pypi user: newfuture password: "${PYPI_PWD}" + skip_cleanup: false distributions: "sdist bdist_wheel" # Your distributions here on: tags: true diff --git a/setup.py b/setup.py index 9d31d98..be465db 100644 --- a/setup.py +++ b/setup.py @@ -24,12 +24,12 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() # Get version from environment vars -if hasattr(environ,'TRAVIS_TAG'): - version = environ['TRAVIS_TAG'] # `TRAVIS_TAG` from Travis -elif hasattr(environ,'BUILD_SOURCEBRANCHNAME'): - version = environ['BUILD_SOURCEBRANCHNAME'] # `BUILD_SOURCEBRANCHNAME` from azure pipelines +if 'TRAVIS_TAG' in environ: + version = environ['TRAVIS_TAG'] # `TRAVIS_TAG` from Travis +elif 'BUILD_SOURCEBRANCHNAME' in environ: + version = environ['BUILD_SOURCEBRANCHNAME'] # from azure pipelines else: - raise Exception("This setup script should be run in CI/CD environment (TravisCI or AzurePipelines)") + raise Exception("setup.py should be run in CI (Travis or AzurePipelines)") version = version.strip('v').strip('V') # Arguments marked as "Required" below must be included for upload to PyPI.