diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml index 211873ce6189..d8acb3a135c6 100644 --- a/.github/workflows/nightlies.yml +++ b/.github/workflows/nightlies.yml @@ -63,3 +63,23 @@ jobs: --user scipy-wheels-nightly \ --skip-existing \ dist/matplotlib-*.whl + + - name: Remove old uploads to save space + shell: bash + run: | + N_LATEST_UPLOADS=5 + + # Remove all _but_ the last "${N_LATEST_UPLOADS}" package versions + # N.B.: `anaconda show` places the newest packages at the bottom of the output + # of the 'Versions' section and package versions are preceded with a ' + '. + anaconda show scipy-wheels-nightly/matplotlib &> >(grep '+') | \ + sed 's/.* + //' | \ + head --lines "-${N_LATEST_UPLOADS}" > remove-package-versions.txt + + if [ -s remove-package-versions.txt ]; then + while LANG=C IFS= read -r package_version ; do + anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} remove \ + --force \ + "scipy-wheels-nightly/matplotlib/${package_version}" + done