Skip to content

Commit

Permalink
删除旧release时同时删除tags
Browse files Browse the repository at this point in the history
  • Loading branch information
chenmozhijin committed Sep 26, 2024
1 parent 665c295 commit 2cd153b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build_helper/utils/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,17 @@ def new_release(cfg: dict, assets: list[str], body: str) -> None:
release.upload_asset(asset)

try:
headers = {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
"Authorization": f'Bearer {token}',
}
for release in releases:
if release.tag_name.endswith(tag_suffix) and release.tag_name != tag_name:
logger.info("删除旧版本: %s", release.tag_name)
release.delete_release()
requests.delete(f"https://api.github.com/repos/{user_repo}/git/refs/tags/{release.tag_name}", headers=headers, timeout=10)

except Exception:
logger.exception("删除旧版本失败")

Expand Down

0 comments on commit 2cd153b

Please sign in to comment.