Cleanup PyPI #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cleanup PyPI | |
on: | |
workflow_call: | |
inputs: | |
environment: | |
description: CI environment to run in (pypi-test or pypi-prod-nightly) | |
type: string | |
required: true | |
subcommand: | |
description: List or Delete | |
type: string | |
default: delete | |
verbosity: | |
description: Tool verbosity ("verbose" or "debug") | |
type: string | |
default: verbose | |
secrets: | |
PYPI_CLEANUP_OTP: | |
description: PyPI OTP | |
required: true | |
PYPI_CLEANUP_PASSWORD: | |
description: PyPI password | |
required: true | |
workflow_dispatch: | |
inputs: | |
subcommand: | |
description: List or Delete | |
type: choice | |
required: true | |
options: | |
- list | |
- delete | |
default: list | |
environment: | |
description: CI environment to run in | |
type: choice | |
required: true | |
options: | |
- pypi-prod-nightly | |
- pypi-test | |
verbosity: | |
description: Tool verbosity | |
type: choice | |
required: true | |
options: | |
- verbose | |
- debug | |
default: verbose | |
jobs: | |
cleanup_pypi: | |
name: Remove Nightlies from PyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ inputs.environment }} | |
env: | |
PYPI_CLEANUP_PASSWORD: ${{secrets.PYPI_CLEANUP_PASSWORD}} | |
PYPI_CLEANUP_OTP: ${{secrets.PYPI_CLEANUP_OTP}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- if: ${{ vars.PYPI_CLEANUP_USERNAME == '' }} | |
run: | | |
echo "Error: PYPI_CLEANUP_USERNAME is not set in CI environment '${{ inputs.environment }}'" | |
exit 1 | |
- if: ${{ vars.PYPI_MAX_NIGHTLIES == '' }} | |
run: | | |
echo "Error: PYPI_MAX_NIGHTLIES is not set in CI environment '${{ inputs.environment }}'" | |
exit 1 | |
- name: Install Astral UV | |
uses: astral-sh/setup-uv@v7 | |
with: | |
version: "0.9.0" | |
- name: Install dependencies | |
run: uv sync --only-group pypi --no-install-project | |
- name: List Stale Packages on PyPI | |
if: inputs.subcommand == 'list' | |
env: | |
PYTHON_UNBUFFERED: 1 | |
run: | | |
set -x | |
uv run --no-sync python -u -m duckdb_packaging.pypi_cleanup \ | |
--${{ inputs.environment == 'pypi-prod-nightly' && 'prod' || 'test' }} \ | |
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }} \ | |
--${{ inputs.verbosity }} \ | |
list 2>&1 | tee cleanup_output | |
- name: Delete Stale Packages from PyPI | |
if: inputs.subcommand == 'delete' | |
env: | |
PYTHON_UNBUFFERED: 1 | |
run: | | |
set -x | |
uv run --no-sync python -u -m duckdb_packaging.pypi_cleanup \ | |
--${{ inputs.environment == 'pypi-prod-nightly' && 'prod' || 'test' }} \ | |
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }} \ | |
--${{ inputs.verbosity }} \ | |
delete --username "${{ vars.PYPI_CLEANUP_USERNAME }}" 2>&1 | tee cleanup_output | |
- name: PyPI Cleanup Summary | |
run : | | |
echo "## PyPI Cleanup Summary" >> $GITHUB_STEP_SUMMARY | |
echo "* Subcommand: ${{ inputs.subcommand }}" >> $GITHUB_STEP_SUMMARY | |
echo "* CI Environment: ${{ inputs.environment }}" >> $GITHUB_STEP_SUMMARY | |
echo "* Output:" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
cat cleanup_output >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY |