mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 14:32:28 +03:00
🏏 incorporate review feedback
This commit is contained in:
parent
a87284cf80
commit
aca98c1355
3 changed files with 52 additions and 31 deletions
|
@ -1117,8 +1117,7 @@ def push_binary_transparency(git_repo_path, git_remote):
|
|||
|
||||
|
||||
def find_release_infos(index_v2_path, repo_dir, package_names):
|
||||
"""
|
||||
Find files, texts, etc. for uploading to a release page in index-v2.json.
|
||||
"""Find files, texts, etc. for uploading to a release page in index-v2.json.
|
||||
|
||||
This function parses index-v2.json for file-paths elegible for deployment
|
||||
to release pages. (e.g. GitHub releases) It also groups these files by
|
||||
|
@ -1137,19 +1136,16 @@ def find_release_infos(index_v2_path, repo_dir, package_names):
|
|||
for version in package.get('versions', {}).values():
|
||||
if package_name not in release_infos:
|
||||
release_infos[package_name] = {}
|
||||
ver_name = version['manifest']['versionName']
|
||||
apk_path = version['file']['name']
|
||||
if apk_path.startswith('/'):
|
||||
apk_path = apk_path[1:]
|
||||
apk_path = repo_dir / apk_path
|
||||
files = [apk_path]
|
||||
asc_path = pathlib.Path(str(apk_path) + '.asc')
|
||||
version_name = version['manifest']['versionName']
|
||||
version_path = repo_dir / version['file']['name'].lstrip("/")
|
||||
files = [version_path]
|
||||
asc_path = pathlib.Path(str(version_path) + '.asc')
|
||||
if asc_path.is_file():
|
||||
files.append(asc_path)
|
||||
idsig_path = pathlib.Path(str(apk_path) + '.idsig')
|
||||
if idsig_path.is_file():
|
||||
files.append(idsig_path)
|
||||
release_infos[package_name][ver_name] = {
|
||||
sig_path = pathlib.Path(str(version_path) + '.sig')
|
||||
if sig_path.is_file():
|
||||
files.append(sig_path)
|
||||
release_infos[package_name][version_name] = {
|
||||
'files': files,
|
||||
'whatsNew': version.get('whatsNew', {}).get("en-US"),
|
||||
'hasReleaseChannels': len(version.get('releaseChannels', [])) > 0,
|
||||
|
@ -1174,24 +1170,41 @@ def upload_to_github_releases(repo_section, gh_config, global_gh_token):
|
|||
for package_name in repo_conf.get('packages', []):
|
||||
package_names.append(package_name)
|
||||
|
||||
release_infos = fdroidserver.deploy.find_release_infos(index_v2_path, repo_dir, package_names)
|
||||
release_infos = fdroidserver.deploy.find_release_infos(
|
||||
index_v2_path, repo_dir, package_names
|
||||
)
|
||||
|
||||
for repo_conf in gh_config:
|
||||
upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token)
|
||||
|
||||
|
||||
def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
||||
repo = repo_conf.get('repo')
|
||||
repo = repo_conf.get("repo")
|
||||
if not repo:
|
||||
logging.warning(_("One of the 'github_releases' config items is missing the 'repo' value. skipping ..."))
|
||||
logging.warning(
|
||||
_(
|
||||
"One of the 'github_releases' config items is missing the "
|
||||
"'repo' value. skipping ..."
|
||||
)
|
||||
)
|
||||
return
|
||||
token = repo_conf.get('token') or global_gh_token
|
||||
token = repo_conf.get("token") or global_gh_token
|
||||
if not token:
|
||||
logging.warning(_("One of the 'github_releases' config itmes is missing the 'token' value. skipping ..."))
|
||||
logging.warning(
|
||||
_(
|
||||
"One of the 'github_releases' config itmes is missing the "
|
||||
"'token' value. skipping ..."
|
||||
)
|
||||
)
|
||||
return
|
||||
packages = repo_conf.get('packages', [])
|
||||
packages = repo_conf.get("packages", [])
|
||||
if not packages:
|
||||
logging.warning(_("One of the 'github_releases' config itmes is missing the 'packages' value. skipping ..."))
|
||||
logging.warning(
|
||||
_(
|
||||
"One of the 'github_releases' config itmes is missing the "
|
||||
"'packages' value. skipping ..."
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
# lookup all versionNames (git tags) for all packages available in the
|
||||
|
@ -1209,14 +1222,23 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
|||
# Making sure we're not uploading this version when releaseChannels
|
||||
# is set. (releaseChannels usually mean it's e.g. an alpha or beta
|
||||
# version)
|
||||
if not release_infos.get(packages[0], {}).get(version, {}).get('hasReleaseChannels'):
|
||||
if (
|
||||
not release_infos.get(packages[0], {})
|
||||
.get(version, {})
|
||||
.get('hasReleaseChannels')
|
||||
):
|
||||
# collect files associated with this github release
|
||||
files = []
|
||||
for package in packages:
|
||||
files.extend(release_infos.get(package, {}).get(version, {}).get('files', []))
|
||||
files.extend(
|
||||
release_infos.get(package, {}).get(version, {}).get('files', [])
|
||||
)
|
||||
# always use the whatsNew text from the first app listed in
|
||||
# config.qml github_releases.packages
|
||||
text = release_infos.get(packages[0], {}).get(version, {}).get('whatsNew') or ''
|
||||
text = (
|
||||
release_infos.get(packages[0], {}).get(version, {}).get('whatsNew')
|
||||
or ''
|
||||
)
|
||||
if 'release_notes_prepend' in repo_conf:
|
||||
text = repo_conf['release_notes_prepend'] + "\n\n" + text
|
||||
# create new release on github and upload all associated files
|
||||
|
@ -1346,7 +1368,9 @@ def main():
|
|||
if config.get('virustotal_apikey'):
|
||||
upload_to_virustotal(repo_section, config.get('virustotal_apikey'))
|
||||
if config.get('github_releases'):
|
||||
upload_to_github_releases(repo_section, config.get('github_releases'), config.get('github_token'))
|
||||
upload_to_github_releases(
|
||||
repo_section, config.get('github_releases'), config.get('github_token')
|
||||
)
|
||||
|
||||
binary_transparency_remote = config.get('binary_transparency_remote')
|
||||
if binary_transparency_remote:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue