---
- name: Prepare wheels for publishing in our cache  # noqa no-changed-when
  ansible.builtin.shell:
    cmd: |
      set -xe
      for pkg in */*.whl
      do
        # do we have this package on server already?
        status=$(curl --head --silent https://snapshots.linaro.org/ldcg/python-cache/${pkg} | head -n 1)
        if $(echo $status | grep -q 404); then
          echo "uploading $pkg"
        else
          rm -rf "{{ wheels_dir }}/$pkg"
        fi
      done
    chdir: "{{ wheels_dir }}"
    executable: "/bin/bash"
