From 291edab5f608679ed3afd2bc2084185c6d6adafa Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 16 Jun 2020 14:48:03 +0000 Subject: [PATCH] Simplify twine invocation for PyPI uploads Modern PyPI no longer requires a separate register step, new projects are registered at the time of upload, so drop the registration tasks. Twine can also upload multiple artifacts in a single invocation, and does so in the order in which they're provided on the command line, thus there's no longer any need for looping or different wheel and sdist tarball upload tasks. Change-Id: I09acaf458af600137c72a70a8782c47b67937b60 --- roles/upload-pypi/tasks/main.yaml | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/roles/upload-pypi/tasks/main.yaml b/roles/upload-pypi/tasks/main.yaml index 7712e56b3..7151e161d 100644 --- a/roles/upload-pypi/tasks/main.yaml +++ b/roles/upload-pypi/tasks/main.yaml @@ -21,19 +21,6 @@ msg: "Found no wheels to upload: {{ found_wheels.msg }}" when: found_wheels.files == [] -- name: Register packages on the PyPI server (via wheels) - command: "{{ pypi_twine_executable }} register --config-file {{ _pypirc_tmp.path }} --repository {{ pypi_repository }} {{ zj_wheel.path }}" - with_items: "{{ found_wheels.files }}" - loop_control: - loop_var: zj_wheel - when: pypi_register_first - -- name: Upload wheel with twine before tarballs - command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ zj_wheel.path }}" - with_items: "{{ found_wheels.files }}" - loop_control: - loop_var: zj_wheel - - name: Find tarballs to upload find: paths: "{{ pypi_path }}" @@ -45,20 +32,8 @@ msg: "Found no tarballs to upload: {{ found_tarballs.msg }}" when: found_tarballs.files == [] -- name: Register packages on the PyPI server (via tarballs) - command: "{{ pypi_twine_executable }} register --config-file {{ _pypirc_tmp.path }} --repository {{ pypi_repository }} {{ zj_tarball.path }}" - with_items: "{{ found_tarballs.files }}" - loop_control: - loop_var: zj_tarball - when: - - pypi_register_first - - found_wheels.files == [] - -- name: Upload tarballs with twine - command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ zj_tarball.path }}" - with_items: "{{ found_tarballs.files }}" - loop_control: - loop_var: zj_tarball +- name: Upload wheels and sdist tarballs with twine + command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ found_wheels.files | map(attribute='path') | join(' ') }} {{ found_tarballs.files | map(attribute='path') | join(' ') }}" - name: Delete .pypirc configuration file file: