From cf8f6f7d28540efea98eb8d26ab6828c143306ba Mon Sep 17 00:00:00 2001 From: orhtej2 <2871798+orhtej2@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:32:24 +0100 Subject: [PATCH] Support for GitLab upstream repos part 2. --- schemas/manifest.v2.schema.json | 5 ++++- .../autoupdate_app_sources.py | 2 +- tools/autoupdate_app_sources/rest_api.py | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/schemas/manifest.v2.schema.json b/schemas/manifest.v2.schema.json index dc364e64..91831cbb 100644 --- a/schemas/manifest.v2.schema.json +++ b/schemas/manifest.v2.schema.json @@ -413,7 +413,10 @@ "enum": [ "latest_github_tag", "latest_github_release", - "latest_github_commit" + "latest_github_commit", + "latest_gitlab_tag", + "latest_gitlab_release", + "latest_gitlab_commit" ] }, "upstream": { diff --git a/tools/autoupdate_app_sources/autoupdate_app_sources.py b/tools/autoupdate_app_sources/autoupdate_app_sources.py index b8da97e1..dfd15b71 100644 --- a/tools/autoupdate_app_sources/autoupdate_app_sources.py +++ b/tools/autoupdate_app_sources/autoupdate_app_sources.py @@ -171,7 +171,7 @@ class AppAutoUpdater: print(f"\n Checking {source} ...") - if strategy == "latest_github_release": + if strategy == "latest_github_release" or strategy == "latest_gitlab_release": ( new_version, new_asset_urls, diff --git a/tools/autoupdate_app_sources/rest_api.py b/tools/autoupdate_app_sources/rest_api.py index 8a79f33c..d7da8a8b 100644 --- a/tools/autoupdate_app_sources/rest_api.py +++ b/tools/autoupdate_app_sources/rest_api.py @@ -88,7 +88,9 @@ class GitlabAPI: def releases(self) -> List[str]: """Get a list of releases for project.""" releases = self.internal_api(f"projects/{self.project_id}/releases") - return [{ + retval = [] + for release in releases: + r = { "tag_name": release["tag_name"], "prerelease": False, "draft": False, @@ -97,7 +99,15 @@ class GitlabAPI: "name": asset["name"], "browser_download_url": asset["direct_asset_url"] } for asset in release["assets"]["links"]], - } for release in releases] + } + for source in release["assets"]["sources"]: + r["assets"].append({ + "name": f"source.{source['format']}", + "browser_download_url": source['url'] + }) + retval.append(r) + + return retval def url_for_ref(self, ref: str, ref_type: RefType) -> str: return f"{self.upstream}/api/v4/projects/{self.project_id}/repository/archive.tar.gz/?sha={ref}"