From bfe2cbe875f81bd8e333796d2594a9cd36806374 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 9 Feb 2018 20:59:15 -0200 Subject: [PATCH] Implement publishing to PyPI by pushing a tag Fix #3060 --- .travis.yml | 20 +++++++++-- HOWTORELEASE.rst | 40 +++++++--------------- changelog/3060.trivial.rst | 1 + tasks/generate.py | 70 ++++---------------------------------- tasks/requirements.txt | 2 -- 5 files changed, 37 insertions(+), 96 deletions(-) create mode 100644 changelog/3060.trivial.rst diff --git a/.travis.yml b/.travis.yml index 40fe3e8baab..b0ed7bf29cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,8 @@ sudo: false language: python python: - '3.6' -# command to install dependencies install: - pip install --upgrade --pre tox -# # command to run tests env: matrix: # coveralls is not listed in tox's envlist, but should run in travis @@ -29,7 +27,7 @@ env: - TOXENV=doctesting - TOXENV=docs -matrix: +jobs: include: - env: TOXENV=pypy python: 'pypy-5.4' @@ -40,6 +38,22 @@ matrix: - env: TOXENV=py37 python: 'nightly' + - stage: deploy + python: '3.6' + env: + install: pip install -U setuptools setuptools_scm + script: skip + deploy: + provider: pypi + user: nicoddemus + distributions: sdist bdist_wheel + skip_upload_docs: true + password: + secure: xanTgTUu6XDQVqB/0bwJQXoDMnU5tkwZc5koz6mBkkqZhKdNOi2CLoC1XhiSZ+ah24l4V1E0GAqY5kBBcy9d7NVe4WNg4tD095LsHw+CRU6/HCVIFfyk2IZ+FPAlguesCcUiJSXOrlBF+Wj68wEvLoK7EoRFbJeiZ/f91Ww1sbtDlqXABWGHrmhPJL5Wva7o7+wG7JwJowqdZg1pbQExsCc7b53w4v2RBu3D6TJaTAzHiVsW+nUSI67vKI/uf+cR/OixsTfy37wlHgSwihYmrYLFls3V0bSpahCim3bCgMaFZx8S8xrdgJ++PzBCof2HeflFKvW+VCkoYzGEG4NrTWJoNz6ni4red9GdvfjGH3YCjAKS56h9x58zp2E5rpsb/kVq5/45xzV+dq6JRuhQ1nJWjBC6fSKAc/bfwnuFK3EBxNLkvBssLHvsNjj5XG++cB8DdS9wVGUqjpoK4puaXUWFqy4q3S9F86HEsKNgExtieA9qNx+pCIZVs6JCXZNjr0I5eVNzqJIyggNgJG6RyravsU35t9Zd9doL5g4Y7UKmAGTn1Sz24HQ4sMQgXdm2SyD8gEK5je4tlhUvfGtDvMSlstq71kIn9nRpFnqB6MFlbYSEAZmo8dGbCquoUc++6Rum208wcVbrzzVtGlXB/Ow9AbFMYeAGA0+N/K1e59c= + on: + tags: true + repo: pytest-dev/pytest + script: tox --recreate notifications: diff --git a/HOWTORELEASE.rst b/HOWTORELEASE.rst index 9a251a8f0e8..97bddf7202b 100644 --- a/HOWTORELEASE.rst +++ b/HOWTORELEASE.rst @@ -22,44 +22,28 @@ taking a lot of time to make a new one. Ensure your are in a clean work tree. -#. Generate docs, changelog, announcements and upload a package to - your ``devpi`` staging server:: +#. Generate docs, changelog, announcements and a **local** tag:: - invoke generate.pre-release --password - - If ``--password`` is not given, it is assumed the user is already logged in ``devpi``. - If you don't have an account, please ask for one. + invoke generate.pre-release #. Open a PR for this branch targeting ``master``. -#. Test the package - - * **Manual method** - - Run from multiple machines:: +#. After all tests pass and the PR has been approved, publish to PyPI by pushing the tag:: - devpi use https://devpi.net/USER/dev - devpi test pytest==VERSION + git push git@github.com:pytest-dev/pytest.git - Check that tests pass for relevant combinations with:: + Wait for the deploy to complete, then make sure it is `available on PyPI `_. - devpi list pytest +#. Send an email announcement with the contents from:: - * **CI servers** + doc/en/announce/release-.rst - Configure a repository as per-instructions on - devpi-cloud-test_ to test the package on Travis_ and AppVeyor_. - All test environments should pass. + To the following mailing lists: -#. Publish to PyPI:: + * pytest-dev@python.org (all releases) + * python-announce-list@python.org (all releases) + * testing-in-python@lists.idyll.org (only major/minor releases) - invoke generate.publish-release - - where PYPI_NAME is the name of pypi.python.org as configured in your ``~/.pypirc`` - file `for devpi `_. + And announce it on `Twitter `_ with the ``#pytest`` hashtag. #. After a minor/major release, merge ``release-X.Y.Z`` into ``master`` and push (or open a PR). - -.. _devpi-cloud-test: https://github.com/obestwalter/devpi-cloud-test -.. _AppVeyor: https://www.appveyor.com/ -.. _Travis: https://travis-ci.org diff --git a/changelog/3060.trivial.rst b/changelog/3060.trivial.rst new file mode 100644 index 00000000000..9ea9871e3f9 --- /dev/null +++ b/changelog/3060.trivial.rst @@ -0,0 +1 @@ +pytest has changed the publication procedure and is now being published to PyPI directly from Travis. diff --git a/tasks/generate.py b/tasks/generate.py index 5aa4752f5d5..bef2edf11d9 100644 --- a/tasks/generate.py +++ b/tasks/generate.py @@ -1,4 +1,6 @@ -import os +""" +Invoke development tasks. +""" from pathlib import Path from subprocess import check_output, check_call @@ -57,7 +59,7 @@ def regen(ctx): @invoke.task() def make_tag(ctx, version): - """Create a new (local) tag for the release, only if the repository is clean.""" + """Create a new, local tag for the release, only if the repository is clean.""" from git import Repo repo = Repo('.') @@ -74,81 +76,24 @@ def make_tag(ctx, version): repo.create_tag(version) -@invoke.task() -def devpi_upload(ctx, version, user, password=None): - """Creates and uploads a package to devpi for testing.""" - if password: - print("[generate.devpi_upload] devpi login {}".format(user)) - check_call(['devpi', 'login', user, '--password', password]) - - check_call(['devpi', 'use', 'https://devpi.net/{}/dev'.format(user)]) - - env = os.environ.copy() - env['SETUPTOOLS_SCM_PRETEND_VERSION'] = version - check_call(['devpi', 'upload', '--formats', 'sdist,bdist_wheel'], env=env) - print("[generate.devpi_upload] package uploaded") - - @invoke.task(help={ 'version': 'version being released', - 'user': 'name of the user on devpi to stage the generated package', - 'password': 'user password on devpi to stage the generated package ' - '(if not given assumed logged in)', }) -def pre_release(ctx, version, user, password=None): - """Generates new docs, release announcements and uploads a new release to devpi for testing.""" +def pre_release(ctx, version): + """Generates new docs, release announcements and creates a local tag.""" announce(ctx, version) regen(ctx) changelog(ctx, version, write_out=True) msg = 'Preparing release version {}'.format(version) check_call(['git', 'commit', '-a', '-m', msg]) - + make_tag(ctx, version) - devpi_upload(ctx, version=version, user=user, password=password) - print() print('[generate.pre_release] Please push your branch and open a PR.') -@invoke.task(help={ - 'version': 'version being released', - 'user': 'name of the user on devpi to stage the generated package', - 'pypi_name': 'name of the pypi configuration section in your ~/.pypirc', -}) -def publish_release(ctx, version, user, pypi_name): - """Publishes a package previously created by the 'pre_release' command.""" - from git import Repo - repo = Repo('.') - tag_names = [x.name for x in repo.tags] - if version not in tag_names: - print('Could not find tag for version {}, exiting...'.format(version)) - raise invoke.Exit(code=2) - - check_call(['devpi', 'use', 'https://devpi.net/{}/dev'.format(user)]) - check_call(['devpi', 'push', 'pytest=={}'.format(version), 'pypi:{}'.format(pypi_name)]) - check_call(['git', 'push', 'git@github.com:pytest-dev/pytest.git', version]) - - emails = [ - 'pytest-dev@python.org', - 'python-announce-list@python.org' - ] - if version.endswith('.0'): - emails.append('testing-in-python@lists.idyll.org') - print('Version {} has been published to PyPI!'.format(version)) - print() - print('Please send an email announcement with the contents from:') - print() - print(' doc/en/announce/release-{}.rst'.format(version)) - print() - print('To the following mail lists:') - print() - print(' ', ','.join(emails)) - print() - print('And announce it on twitter adding the #pytest hash tag.') - - @invoke.task(help={ 'version': 'version being released', 'write_out': 'write changes to the actual changelog' @@ -159,4 +104,3 @@ def changelog(ctx, version, write_out=False): else: addopts = ['--draft'] check_call(['towncrier', '--version', version] + addopts) - diff --git a/tasks/requirements.txt b/tasks/requirements.txt index be4bff99060..7f41521e6a2 100644 --- a/tasks/requirements.txt +++ b/tasks/requirements.txt @@ -1,6 +1,4 @@ -devpi-client gitpython invoke towncrier tox -wheel