Cleanup PyPI #19
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 | |
secrets: | |
PYPI_CLEANUP_OTP: | |
description: PyPI OTP | |
required: true | |
PYPI_CLEANUP_PASSWORD: | |
description: PyPI password | |
required: true | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: List packages that would be deleted but don't delete them | |
type: boolean | |
default: false | |
environment: | |
description: CI environment to run in | |
type: choice | |
required: true | |
options: | |
- pypi-prod-nightly | |
- pypi-test | |
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@v6 | |
with: | |
version: "0.7.14" | |
- name: Run Cleanup | |
env: | |
PYTHON_UNBUFFERED: 1 | |
run: | | |
set -x | |
uv sync --only-group pypi --no-install-project | |
uv run --no-sync python -u -m duckdb_packaging.pypi_cleanup ${{ inputs.dry-run && '--dry' || '' }} \ | |
${{ inputs.environment == 'pypi-prod-nightly' && '--prod' || '--test' }} \ | |
--username "${{ vars.PYPI_CLEANUP_USERNAME }}" \ | |
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }} 2>&1 | tee cleanup_output | |
- name: PyPI Cleanup Summary | |
run : | | |
echo "## PyPI Cleanup Summary" >> $GITHUB_STEP_SUMMARY | |
echo "* Dry run: ${{ inputs.dry-run }}" >> $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 |