
This does a full upload of the sandbox project to the test.pypi.org service. It uses the inline token with the caveats noted in the comment. Since you can't upload the same version twice, always running this in the check job will mean it will work the first time, but then fail (unless something has been committed to the sandbox to update the version number). As noted, the idea is that we develop the change and then do one run that does a full test, and reviewers can check that before committing. There's no real way to use a secret here because we actually want this to run at check time, not in any post pipeline where it would already be in production. We don't want to do something like require committing something to sandbox every time you run this in the check queue, etc. Given how much this is actually updated (most of it hasn't been touched since 2019) I think this is a reasonable compromise. Change-Id: Ida4ad07c82a6301107c938565656988aba3bf250
54 lines
1.6 KiB
YAML
54 lines
1.6 KiB
YAML
# NOTE(ianw) 2022-07 : If you modify this, see the comments about
|
|
# testing in test-playbooks/python/upload-pypi.yaml. Once the change
|
|
# is finalised, you should do one run that uploads the sandbox project
|
|
# to test.pypi.org to validate the full path.
|
|
|
|
- name: Validate password/token combo
|
|
fail:
|
|
msg: 'Specify either username/password or api_token'
|
|
when: >
|
|
(pypi_info.api_token is defined) and
|
|
((pypi_info.username is defined) or (pypi_info.password is defined))
|
|
|
|
- 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
|