Browse Source

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

changes/34/634934/3
Zuul 5 months ago
parent
commit
bb0788ff0c

+ 6
- 0
roles/upload-pypi/README.rst View File

@@ -35,3 +35,9 @@ Upload python packages to PyPI
35 35
    :default: twine
36 36
 
37 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.

+ 1
- 0
roles/upload-pypi/defaults/main.yaml View File

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

+ 12
- 0
roles/upload-pypi/tasks/main.yaml View File

@@ -20,6 +20,11 @@
20 20
     msg: "Found no wheels to upload: {{found_wheels.msg}}"
21 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 28
 - name: Upload wheel with twine before tarballs
24 29
   command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}"
25 30
   with_items: "{{ found_wheels.files }}"
@@ -35,6 +40,13 @@
35 40
     msg: "Found no tarballs to upload: {{found_tarballs.msg}}"
36 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 50
 - name: Upload tarballs with twine
39 51
   command: "{{ pypi_twine_executable }} upload --config-file {{ _pypirc_tmp.path }} -r {{ pypi_repository }} {{ item.path }}"
40 52
   with_items: "{{ found_tarballs.files }}"

Loading…
Cancel
Save