Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b37e696094 | ||
|
|
289ce65431 | ||
|
|
704ce3bef2 |
70
build.py
70
build.py
@@ -182,9 +182,8 @@ def build():
|
||||
# Auto-deploy: sync shared files so Claude Code always has the latest
|
||||
deploy_shared_files()
|
||||
|
||||
# Publish release to Gitea + cleanup old remote releases
|
||||
# Publish release to Gitea
|
||||
publish_gitea_release(dst)
|
||||
cleanup_gitea_releases()
|
||||
|
||||
|
||||
def _get_gitea_auth() -> dict:
|
||||
@@ -312,60 +311,6 @@ def _version_key(path: str):
|
||||
return (0, 0, 0)
|
||||
|
||||
|
||||
def _tag_version_key(tag_name: str):
|
||||
"""Extract (major, minor, patch) from tag like 'v1.9.5'."""
|
||||
m = re.match(r'v(\d+)\.(\d+)\.(\d+)', tag_name)
|
||||
if m:
|
||||
return (int(m.group(1)), int(m.group(2)), int(m.group(3)))
|
||||
return (0, 0, 0)
|
||||
|
||||
|
||||
def cleanup_gitea_releases():
|
||||
"""Keep the first release (v1.0.0) and the last 5 releases on Gitea, delete the rest."""
|
||||
auth = _get_gitea_auth()
|
||||
if not auth:
|
||||
return
|
||||
|
||||
# List all releases
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
f"{_GITEA_API}/releases?limit=50",
|
||||
headers=auth,
|
||||
)
|
||||
resp = urllib.request.urlopen(req, timeout=30)
|
||||
releases = json.loads(resp.read())
|
||||
except Exception as e:
|
||||
print(f"Gitea release list failed: {e}")
|
||||
return
|
||||
|
||||
if len(releases) <= 6:
|
||||
return
|
||||
|
||||
# Sort by semver
|
||||
releases.sort(key=lambda r: _tag_version_key(r.get("tag_name", "")))
|
||||
|
||||
first = releases[0]
|
||||
last_5 = releases[-5:]
|
||||
keep_ids = {first["id"]} | {r["id"] for r in last_5}
|
||||
|
||||
removed = []
|
||||
for r in releases:
|
||||
if r["id"] in keep_ids:
|
||||
continue
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
f"{_GITEA_API}/releases/{r['id']}",
|
||||
headers=auth,
|
||||
method="DELETE",
|
||||
)
|
||||
urllib.request.urlopen(req, timeout=15)
|
||||
removed.append(r.get("tag_name", "?"))
|
||||
except Exception as e:
|
||||
print(f"Failed to delete Gitea release {r.get('tag_name')}: {e}")
|
||||
|
||||
if removed:
|
||||
print(f"Cleaned {len(removed)} old Gitea releases: {', '.join(removed)}")
|
||||
|
||||
|
||||
def cleanup_old_releases():
|
||||
"""Keep the first release (v1.0.0) and the last 5 releases, delete the rest."""
|
||||
@@ -383,9 +328,20 @@ def cleanup_old_releases():
|
||||
keep = set([first] + last_5)
|
||||
|
||||
removed = []
|
||||
_flags = subprocess.CREATE_NO_WINDOW if sys.platform == "win32" else 0
|
||||
for f in all_exes:
|
||||
if f not in keep:
|
||||
os.remove(f)
|
||||
# Use git rm so deletion is staged for commit
|
||||
try:
|
||||
subprocess.run(
|
||||
["git", "rm", "-f", "--quiet", f],
|
||||
cwd=PROJECT_DIR, creationflags=_flags,
|
||||
capture_output=True,
|
||||
)
|
||||
except Exception:
|
||||
# Fallback: just delete the file
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
removed.append(os.path.basename(f))
|
||||
|
||||
if removed:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
"""Version info for ServerManager."""
|
||||
|
||||
__version__ = "1.9.11"
|
||||
__version__ = "1.9.13"
|
||||
__app_name__ = "ServerManager"
|
||||
__author__ = "aibot777"
|
||||
__description__ = "Desktop GUI for managing remote servers"
|
||||
|
||||
Reference in New Issue
Block a user