Skip to content

Add a separate action for removing old wheels #422

Add a separate action for removing old wheels

Add a separate action for removing old wheels #422

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Run weekly at 1:23 UTC
schedule:
- cron: '23 1 * * 0'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: "test upload via action"
runs-on: ubuntu-latest
if: github.repository == 'scientific-python/upload-nightly-action'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# Don't rely on the action's path being in the current directory
with:
path: '_action_path'
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.x'
- name: Install the latest version of uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Build v0.0.1 wheel and sdist
run: |
uv tool run --from build pyproject-build --installer=uv --outdir ./dist _action_path/tests/test_package
- name: Verify the distribution
run: uv tool run twine check --strict dist/*
- name: List contents of sdist
run: python -m tarfile --list dist/test_package-*.tar.gz
- name: List contents of wheel
run: python -m zipfile --list dist/test_package-*.whl
- name: Test upload
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
- name: Test upload that forces removal first
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
- name: Build v0.0.2 wheel and sdist
run: |
# Bump version to avoid wheel name conflicts
sed -i 's/0.0.1/0.0.2/g' _action_path/tests/test_package/pyproject.toml
rm ./dist/*
uv tool run --from build pyproject-build --installer=uv --outdir ./dist _action_path/tests/test_package
- name: Test upload with non-main label
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
anaconda_nightly_upload_labels: test
- name: Build v0.0.3 wheel and sdist
run: |
# Bump version to avoid wheel name conflicts
sed -i 's/0.0.2/0.0.3/g' _action_path/tests/test_package/pyproject.toml
rm ./dist/*
uv tool run --from build pyproject-build --installer=uv --outdir ./dist _action_path/tests/test_package
- name: Test upload with multiple labels
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
anaconda_nightly_upload_labels: dev,test
cleanup:
runs-on: ubuntu-latest
needs: [test]
# Set required workflow secrets in the environment for additional security
# https://github.com/scientific-python/upload-nightly-action/settings/environments
environment:
name: remove-old-wheels
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# Dogfood the remove-wheels action on PRs here. If we keep zero uploads,
# it marks every version of the package for removal.
- name: Remove test package uploads via the action
uses: ./remove-wheels
with:
n_latest_uploads_to_keep: 0
anaconda_nightly_upload_organization: scientific-python-nightly-wheels
anaconda_nightly_token: ${{ secrets.ANACONDA_TOKEN }}
package_name: test-package
# The action removes per version, so delete the (now empty) package
# registration as well
- name: Set up pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
with:
locked: true
- name: Remove the empty test package
shell: pixi run --manifest-path pixi.toml bash -e {0}
run: |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} remove \
--force \
"scientific-python-nightly-wheels/test-package"