zuul-jobs/roles/upload-pypi/tasks/main.yaml
Jeremy Stanley 291edab5f6 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
2020-06-18 18:43:43 +00:00

42 lines
1.2 KiB
YAML

- name: Create .pypirc configuration file tempfile
tempfile:
state: file
register: _pypirc_tmp
- name: Create .pypirc configuration file
template:
dest: "{{ _pypirc_tmp.path }}"
mode: 0400
src: .pypirc.j2
- name: Find wheels to upload
find:
paths: "{{ pypi_path }}"
patterns: "*.whl"
excludes: "*-linux_x86_64.whl"
register: found_wheels
- name: Report no wheels to be uploaded
debug:
msg: "Found no wheels to upload: {{ found_wheels.msg }}"
when: found_wheels.files == []
- name: Find tarballs to upload
find:
paths: "{{ pypi_path }}"
patterns: "*.tar.gz"
register: found_tarballs
- name: Report no tarballs to be uploaded
debug:
msg: "Found no tarballs to upload: {{ found_tarballs.msg }}"
when: found_tarballs.files == []
- 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:
path: "{{ _pypirc_tmp.path }}"
state: absent