Merge "upload-pypi: add option to register packages"

This commit is contained in:
Zuul 2019-02-05 16:11:34 +00:00 committed by Gerrit Code Review
commit bb0788ff0c
3 changed files with 19 additions and 0 deletions

View File

@ -35,3 +35,9 @@ Upload python packages to PyPI
:default: twine :default: twine
Path to twine executable. Path to twine executable.
.. zuul:rolevar:: pypi_register_first
:default: false
Whether the role should register the package before uploading it. This may
be required when uploading for the first time to a devPI instance.

View File

@ -3,3 +3,4 @@ pypi_path: "src/{{ zuul.project.canonical_name }}/dist"
pypi_repository: "{{ pypi_info.repository|default('pypi') }}" pypi_repository: "{{ pypi_info.repository|default('pypi') }}"
pypi_repository_url: "{{ pypi_info.repository_url|default(None) }}" pypi_repository_url: "{{ pypi_info.repository_url|default(None) }}"
pypi_twine_executable: twine pypi_twine_executable: twine
pypi_register_first: false

View File

@ -20,6 +20,11 @@
msg: "Found no wheels to upload: {{found_wheels.msg}}" msg: "Found no wheels to upload: {{found_wheels.msg}}"
when: found_wheels.files == [] 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 }} {{ item.path }}"
with_items: "{{ found_wheels.files }}"
when: pypi_register_first
- name: Upload wheel with twine before tarballs - name: Upload wheel with twine before tarballs
command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}" command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}"
with_items: "{{ found_wheels.files }}" with_items: "{{ found_wheels.files }}"
@ -35,6 +40,13 @@
msg: "Found no tarballs to upload: {{found_tarballs.msg}}" msg: "Found no tarballs to upload: {{found_tarballs.msg}}"
when: found_tarballs.files == [] 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 }} {{ item.path }}"
with_items: "{{ found_tarballs.files }}"
when:
- pypi_register_first
- found_wheels.files == []
- name: Upload tarballs with twine - name: Upload tarballs with twine
command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}" command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}"
with_items: "{{ found_tarballs.files }}" with_items: "{{ found_tarballs.files }}"