1
0
Fork 0

autoupdate app source: add boring 'force_version' parameter for cases where the upstreams don't give a flying fuck about pushi proper tags/releases...

This commit is contained in:
Alexandre Aubin 2023-04-04 18:32:12 +02:00
parent a5b799cc7c
commit 7570123088

View file

@ -6,6 +6,7 @@ import requests
import toml import toml
import os import os
import glob import glob
from datetime import datetime
STRATEGIES = ["latest_github_release", "latest_github_tag", "latest_github_commit"] STRATEGIES = ["latest_github_release", "latest_github_tag", "latest_github_commit"]
@ -161,7 +162,7 @@ class AppAutoUpdater:
asset = infos.get("autoupdate", {}).get("asset", "tarball") asset = infos.get("autoupdate", {}).get("asset", "tarball")
print(f"Checking {source} ...") print(f"\n Checking {source} ...")
new_version, new_asset_urls = self.get_latest_version_and_asset( new_version, new_asset_urls = self.get_latest_version_and_asset(
strategy, asset, infos, source strategy, asset, infos, source
@ -169,34 +170,25 @@ class AppAutoUpdater:
if source == "main": if source == "main":
print(f"Current version in manifest: {self.current_version}") print(f"Current version in manifest: {self.current_version}")
print(f"Newest version on upstream: {new_version}") print(f"Newest version on upstream: {new_version}")
if self.current_version == new_version:
print( if isinstance(new_asset_urls, str) and infos["url"] == new_asset_urls:
f"Version is still {new_version}, no update required for {source}" print(f"URL for asset {source} is up to date")
) continue
continue elif isinstance(new_asset_urls, dict) and new_asset_urls == {
else: k: infos[k]["url"] for k in new_asset_urls.keys()
print(f"Update needed for {source}") }:
todos[source] = { print(f"URLs for asset {source} are up to date")
"new_asset_urls": new_asset_urls, continue
"old_assets": infos,
"new_version": new_version,
}
else: else:
if isinstance(new_asset_urls, str) and infos["url"] == new_asset_urls: print(f"Update needed for {source}")
print(f"URL is still up to date for asset {source}") todos[source] = {
continue "new_asset_urls": new_asset_urls,
elif isinstance(new_asset_urls, dict) and new_asset_urls == { "old_assets": infos,
k: infos[k]["url"] for k in new_asset_urls.keys() }
}:
print(f"URLs are still up to date for asset {source}") if source == "main":
continue todos[source]["new_version"] = new_version
else:
print(f"Update needed for {source}")
todos[source] = {
"new_asset_urls": new_asset_urls,
"old_assets": infos,
}
if dry_run or not todos: if dry_run or not todos:
return bool(todos) return bool(todos)
@ -342,9 +334,9 @@ class AppAutoUpdater:
latest_commit = commits[0] latest_commit = commits[0]
latest_tarball = f"https://github.com/{upstream_repo}/archive/{latest_commit['sha']}.tar.gz" latest_tarball = f"https://github.com/{upstream_repo}/archive/{latest_commit['sha']}.tar.gz"
# Let's have the version as something like "2023.01.23" # Let's have the version as something like "2023.01.23"
latest_version = latest_commit["commit"]["author"]["date"][:10].replace( latest_commit_date = datetime.strptime(latest_commit["commit"]["author"]["date"][:10], "%Y-%M-%d")
"-", "." version_format = infos.get("autoupdate", {}).get("force_version", "%Y.%M.%d")
) latest_version = latest_commit_date.strftime(version_format)
return latest_version, latest_tarball return latest_version, latest_tarball