diff --git a/autorelease-travis.yml b/autorelease-travis.yml index 9662793..6719230 100644 --- a/autorelease-travis.yml +++ b/autorelease-travis.yml @@ -1,8 +1,8 @@ -# AUTORELEASE v0.1.1 +# AUTORELEASE v0.1.2 # for nonrelease, use @master # for release, use v${VERSION}, e.g., v1.0.0 import: - - dwhswenson/autorelease:travis_stages/deploy_testpypi.yml@v0.1.1 - - dwhswenson/autorelease:travis_stages/cut_release.yml@v0.1.1 - - dwhswenson/autorelease:travis_stages/deploy_pypi.yml@v0.1.1 - - dwhswenson/autorelease:travis_stages/test_testpypi.yml@v0.1.1 + - dwhswenson/autorelease:travis_stages/deploy_testpypi.yml@v0.1.2 + - dwhswenson/autorelease:travis_stages/cut_release.yml@v0.1.2 + - dwhswenson/autorelease:travis_stages/deploy_pypi.yml@v0.1.2 + - dwhswenson/autorelease:travis_stages/test_testpypi.yml@v0.1.2 diff --git a/autorelease/scripts/bump_dev_version.py b/autorelease/scripts/bump_dev_version.py index da22e59..62dc29d 100644 --- a/autorelease/scripts/bump_dev_version.py +++ b/autorelease/scripts/bump_dev_version.py @@ -1,18 +1,26 @@ import argparse import time + try: from configparser import ConfigParser, NoSectionError, NoOptionError except ImportError: # py2 from ConfigParser import ConfigParser, NoSectionError, NoOptionError + +from json import JSONDecodeError + from packaging.version import Version import requests def get_latest_pypi(package, index="https://test.pypi.org/pypi"): url = "/".join([index, package, 'json']) req = requests.get(url) - version = max([Version(v) for v in req.json()['releases'].keys()]) + try: + version = max([Version(v) for v in req.json()['releases'].keys()]) + except JSONDecodeError: + # couldn't find a version, so we're okay + version = "0.0.0.dev0" return str(version) def _strip_dev(version_str): diff --git a/devtools/conda-recipe/meta.yaml b/devtools/conda-recipe/meta.yaml index 73c1ed1..ca181fe 100644 --- a/devtools/conda-recipe/meta.yaml +++ b/devtools/conda-recipe/meta.yaml @@ -1,7 +1,7 @@ package: name: autorelease # add ".dev0" for unreleased versions - version: "0.1.1" + version: "0.1.2" source: path: ../../ diff --git a/setup.cfg b/setup.cfg index 15c870d..c68f1c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = autorelease -version = 0.1.1 +version = 0.1.2 # version should end in .dev0 if this isn't to be released short_description = Tools to keep the release process clean. description = Tools to keep the release process clean. diff --git a/setup.py b/setup.py index 2937037..cf559c8 100644 --- a/setup.py +++ b/setup.py @@ -76,11 +76,7 @@ def __init__(self, import_name): def visit_ImportFrom(self, node): if node.module == self.import_name: - replacement = ast.Raise(exc=ast.Call( - func=ast.Name(id='ImportError', ctx=ast.Load()), - args=[], - keywords=[], - ), cause=None) + replacement = ast.parse("raise ImportError()").body[0] return ast.copy_location(replacement, node) else: return node diff --git a/travis_stages/cut_release.yml b/travis_stages/cut_release.yml index 28c6691..c2ec5a7 100644 --- a/travis_stages/cut_release.yml +++ b/travis_stages/cut_release.yml @@ -5,9 +5,14 @@ jobs: # release based on the current stable branch and the release notes # from the last PR merged into stable. if: "(branch = stable) and (not type in (pull_request, cron))" + before_install: skip install: - pip install autorelease + before_script: skip script: - VERSION=`python setup.py --version` - PROJECT=`python setup.py --name` - autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN + after_success: skip + after_failure: skip + after_script: skip diff --git a/travis_stages/deploy_pypi.yml b/travis_stages/deploy_pypi.yml index e5e4887..d77a6bf 100644 --- a/travis_stages/deploy_pypi.yml +++ b/travis_stages/deploy_pypi.yml @@ -4,8 +4,13 @@ jobs: # This stage runs when a version-labelled tag is made. It deploys the # package to PyPI. if: tag =~ ^v[0-9]+\. + before_install: skip install: skip + before_script: skip + before_cache: skip script: skip + after_success: 'true' + # before_deploy is allowed deploy: provider: pypi distributions: sdist bdist_wheel @@ -14,3 +19,4 @@ jobs: on: tags: true password: $TWINE_PASSWORD + after_script: skip diff --git a/travis_stages/deploy_testpypi.yml b/travis_stages/deploy_testpypi.yml index fccf600..deeb25b 100644 --- a/travis_stages/deploy_testpypi.yml +++ b/travis_stages/deploy_testpypi.yml @@ -4,16 +4,25 @@ jobs: # This stage runs when you make a PR to stable. It tests that the # deployment to testpypi works. if: "(branch = stable) and (type = pull_request)" + before_install: skip install: - pip install twine - pip install autorelease + #- pip install git+https://github.com/dwhswenson/autorelease@ops_fixes # this is for debugging anything in autorelease used here (change # the branch tag to whatever is needed) #- pip install git+https://github.com/dwhswenson/autorelease.git@release-0.0.18#egg=autorelease - hash -r + before_script: + - if [ -z "$TWINE_USERNAME" ] ; then echo "Missing TWINE_USERNAME"; fi + - if [ -z "$TWINE_PASSWORD" ] ; then echo "Missing TWINE_PASSWORD"; fi script: - bump-dev-version # comes from autorelease - python setup.py --version - python setup.py sdist bdist_wheel - twine check dist/* - twine upload --repository-url https://test.pypi.org/legacy/ dist/* + after_success: skip + after_failure: skip + # deploy stuff won't be run on PR; don't need to override + after_script: skip diff --git a/travis_stages/test_testpypi.yml b/travis_stages/test_testpypi.yml index 5da4511..fbd6cfd 100644 --- a/travis_stages/test_testpypi.yml +++ b/travis_stages/test_testpypi.yml @@ -5,8 +5,10 @@ jobs: # been deployed to testpypi. It checks that the deployed package # works. if: "(branch = stable) and (type = pull_request)" + before_install: skip install: - pip install autorelease + #- pip install git+https://github.com/dwhswenson/autorelease@ops_fixes # this is for debugging anything in autorelease used here (change # the branch tag to whatever is needed) #- pip install git+https://github.com/dwhswenson/autorelease.git@release-0.0.18#egg=autorelease @@ -16,6 +18,7 @@ jobs: - export VERSION=`pypi-max-version $PROJECT` - echo "Installing ${PROJECT}==${VERSION} (allowing pre-releases)" - pip install --pre --force-reinstall --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple ${PROJECT}==${VERSION} + before_script: skip script: | if [ -n "$AUTORELEASE_TEST_TESTPYPI" ]; then eval $AUTORELEASE_TEST_TESTPYPI @@ -24,3 +27,6 @@ jobs: python -c "import $PROJECT" py.test --pyargs $PROJECT fi + after_failure: skip + after_success: skip + after_script: skip