Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
f63ef85dd7 | |||
c2013fc205
|
|||
e5015ec2f3 | |||
1163744af9
|
|||
e3c703aa32 | |||
aff319cc5f
|
|||
fc8b885214
|
|||
7067f0872b
|
45
.gitea/scripts/cleanup_versions.sh
Executable file
45
.gitea/scripts/cleanup_versions.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# cleanup_dev_versions.sh - Delete old PyPI dev versions from Gitea package registry
|
||||
|
||||
# Required environment variables
|
||||
USERNAME="${TWINE_USERNAME}"
|
||||
TOKEN="${TWINE_PASSWORD}"
|
||||
REPO="${GITHUB_REPOSITORY}" # e.g., maxp/repocat
|
||||
API_BASE="${GITHUB_API_URL%/}" # Strip trailing slash if present
|
||||
|
||||
OWNER="${REPO%%/*}"
|
||||
PACKAGE_NAME="${REPO##*/}"
|
||||
API_URL="${API_BASE}/packages/${OWNER}/pypi/${PACKAGE_NAME}"
|
||||
|
||||
# Fetch the list of versions
|
||||
response=$(curl -s -u "$USERNAME:$TOKEN" "$API_URL")
|
||||
|
||||
# Extract all .dev versions, sort by creation time
|
||||
mapfile -t versions_to_delete < <(echo "$response" | jq -r '
|
||||
map(select(.version | test("\\.dev"))) |
|
||||
sort_by(.created_at) |
|
||||
.[0:-1][] |
|
||||
.version')
|
||||
|
||||
# Determine latest version to keep
|
||||
latest_version=$(echo "$response" | jq -r '
|
||||
map(select(.version | test("\\.dev"))) |
|
||||
sort_by(.created_at) |
|
||||
last.version')
|
||||
|
||||
if [[ -z "$latest_version" || ${#versions_to_delete[@]} -eq 0 ]]; then
|
||||
echo "No old .dev versions to delete."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Keeping latest .dev version: $latest_version"
|
||||
|
||||
# Delete old .dev versions
|
||||
for version in "${versions_to_delete[@]}"; do
|
||||
echo "Deleting old .dev version: $version"
|
||||
curl -s -X DELETE -u "$USERNAME:$TOKEN" "$API_URL/$version"
|
||||
done
|
||||
|
||||
echo "Cleanup complete."
|
@@ -53,3 +53,10 @@ jobs:
|
||||
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
|
||||
run: |
|
||||
poetry run twine upload --repository-url ${{ secrets.TWINE_URL }} dist/*
|
||||
|
||||
- name: Cleanup old dev versions
|
||||
run: |
|
||||
.gitea/scripts/cleanup_versions.sh '\.dev'
|
||||
env:
|
||||
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
|
||||
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
*__pycache__*
|
||||
dist/
|
||||
**/.env
|
13
CHANGELOG.md
13
CHANGELOG.md
@@ -2,6 +2,19 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [unreleased]
|
||||
|
||||
### 🚀 Features
|
||||
|
||||
- *(workflows)* Add cleanup step for old dev versions - ([aff319c](https://git.0xmax42.io/maxp/repoCat/commit/aff319cc5f5c8f954367a6a6b89c84ece6b19f4e))
|
||||
- *(scripts)* Add script to clean old PyPI dev versions - ([fc8b885](https://git.0xmax42.io/maxp/repoCat/commit/fc8b885214b1f5b1d9dcff20612a583aca89f6f9))
|
||||
|
||||
### ⚙️ Miscellaneous Tasks
|
||||
|
||||
- *(scripts)* Update file mode to make script executable - ([c2013fc](https://git.0xmax42.io/maxp/repoCat/commit/c2013fc20538a377fc5de45bd384b6ac438fb61c))
|
||||
- *(scripts)* Rename cleanup script for broader usage - ([1163744](https://git.0xmax42.io/maxp/repoCat/commit/1163744af9a3d908d6e7dbb716818bd67ec76a63))
|
||||
- *(gitignore)* Update ignored files for environment and build - ([7067f08](https://git.0xmax42.io/maxp/repoCat/commit/7067f0872bdd8b456d52b3f9dab4834fd0798977))
|
||||
|
||||
## [0.2.0](https://git.0xmax42.io/maxp/repoCat/compare/v0.1.0..v0.2.0) - 2025-05-11
|
||||
|
||||
### 🚀 Features
|
||||
|
Reference in New Issue
Block a user