summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhuin <mhuin@redhat.com>2019-01-07 18:16:56 +0100
committerMatthieu Huin <mhuin@redhat.com>2019-01-08 07:49:43 +0000
commitfa9cb2f468eb4d8a45c7cc0aef4afe8070ffb55a (patch)
tree31ac5bc869062bba23aadec53e255813ff38ef6c
parent0630797da82ce49b4904de90892d696ddb043d5d (diff)
upload-pypi: add option to register packages
When uploading packages to a devPI instance, the role fails if the packages are not registered first. Since this is not required on PyPI, this adds the "pypi_register_first" option to the role so that users can choose to do so. Change-Id: I2b50362e485175d51840e49ffc09a734b44ec85d
Notes
Notes (review): Code-Review+1: Javier Peña <jpena@redhat.com> Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+1: Nicolas Hicher <nhicher@redhat.com> Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Code-Review+2: Mohammed Naser <mnaser@vexxhost.com> Workflow+1: Mohammed Naser <mnaser@vexxhost.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 05 Feb 2019 16:11:34 +0000 Reviewed-on: https://review.openstack.org/629018 Project: openstack-infra/zuul-jobs Branch: refs/heads/master
-rw-r--r--roles/upload-pypi/README.rst6
-rw-r--r--roles/upload-pypi/defaults/main.yaml1
-rw-r--r--roles/upload-pypi/tasks/main.yaml12
3 files changed, 19 insertions, 0 deletions
diff --git a/roles/upload-pypi/README.rst b/roles/upload-pypi/README.rst
index cbcc0da..aba4b56 100644
--- a/roles/upload-pypi/README.rst
+++ b/roles/upload-pypi/README.rst
@@ -35,3 +35,9 @@ Upload python packages to PyPI
35 :default: twine 35 :default: twine
36 36
37 Path to twine executable. 37 Path to twine executable.
38
39.. zuul:rolevar:: pypi_register_first
40 :default: false
41
42 Whether the role should register the package before uploading it. This may
43 be required when uploading for the first time to a devPI instance.
diff --git a/roles/upload-pypi/defaults/main.yaml b/roles/upload-pypi/defaults/main.yaml
index c0cb93b..1d4b750 100644
--- a/roles/upload-pypi/defaults/main.yaml
+++ b/roles/upload-pypi/defaults/main.yaml
@@ -3,3 +3,4 @@ pypi_path: "src/{{ zuul.project.canonical_name }}/dist"
3pypi_repository: "{{ pypi_info.repository|default('pypi') }}" 3pypi_repository: "{{ pypi_info.repository|default('pypi') }}"
4pypi_repository_url: "{{ pypi_info.repository_url|default(None) }}" 4pypi_repository_url: "{{ pypi_info.repository_url|default(None) }}"
5pypi_twine_executable: twine 5pypi_twine_executable: twine
6pypi_register_first: false
diff --git a/roles/upload-pypi/tasks/main.yaml b/roles/upload-pypi/tasks/main.yaml
index 864fe4d..fb5c10c 100644
--- a/roles/upload-pypi/tasks/main.yaml
+++ b/roles/upload-pypi/tasks/main.yaml
@@ -20,6 +20,11 @@
20 msg: "Found no wheels to upload: {{found_wheels.msg}}" 20 msg: "Found no wheels to upload: {{found_wheels.msg}}"
21 when: found_wheels.files == [] 21 when: found_wheels.files == []
22 22
23- name: Register packages on the PyPI server (via wheels)
24 command: "{{ pypi_twine_executable }} register --config-file {{ _pypirc_tmp.path }} --repository {{ pypi_repository }} {{ item.path }}"
25 with_items: "{{ found_wheels.files }}"
26 when: pypi_register_first
27
23- name: Upload wheel with twine before tarballs 28- name: Upload wheel with twine before tarballs
24 command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}" 29 command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}"
25 with_items: "{{ found_wheels.files }}" 30 with_items: "{{ found_wheels.files }}"
@@ -35,6 +40,13 @@
35 msg: "Found no tarballs to upload: {{found_tarballs.msg}}" 40 msg: "Found no tarballs to upload: {{found_tarballs.msg}}"
36 when: found_tarballs.files == [] 41 when: found_tarballs.files == []
37 42
43- name: Register packages on the PyPI server (via tarballs)
44 command: "{{ pypi_twine_executable }} register --config-file {{ _pypirc_tmp.path }} --repository {{ pypi_repository }} {{ item.path }}"
45 with_items: "{{ found_tarballs.files }}"
46 when:
47 - pypi_register_first
48 - found_wheels.files == []
49
38- name: Upload tarballs with twine 50- name: Upload tarballs with twine
39 command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}" 51 command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}"
40 with_items: "{{ found_tarballs.files }}" 52 with_items: "{{ found_tarballs.files }}"