mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
🏏 incorporate review feedback
This commit is contained in:
parent
a87284cf80
commit
aca98c1355
3 changed files with 52 additions and 31 deletions
|
@ -212,19 +212,19 @@
|
||||||
# index_only: true
|
# index_only: true
|
||||||
|
|
||||||
|
|
||||||
# These settings allows using `fdroid deploy` for publishing APK files from
|
# These settings allow using `fdroid deploy` for publishing APK files from
|
||||||
# your repository to GitHub Releases. (You should also run `fdroid update`
|
# your repository to GitHub Releases. (You should also run `fdroid update`
|
||||||
# every time before deploying to GitHub releases to update index files.) Here's
|
# every time before deploying to GitHub releases to update index files.) Here's
|
||||||
# an example for this deployment automation:
|
# an example for this deployment automation:
|
||||||
# https://github.com/f-droid/fdroidclient/releases/
|
# https://github.com/f-droid/fdroidclient/releases/
|
||||||
#
|
#
|
||||||
# Currently versions which are assigned to a release channel (e.g. alpha or
|
# Currently, versions which are assigned to a release channel (e.g. alpha or
|
||||||
# beta releases) are ignored.
|
# beta releases) are ignored.
|
||||||
#
|
#
|
||||||
# In the examble below tokens are read from environment variables. Putting
|
# In the example below, tokens are read from environment variables. Putting
|
||||||
# tokens directly into the config file is also supported but discouraged. It is
|
# tokens directly into the config file is also supported but discouraged. It is
|
||||||
# highly recommended to use a "Fine-grained personal access token", which is
|
# highly recommended to use a "Fine-grained personal access token", which is
|
||||||
# restriced to the minimum required permissions, which are:
|
# restricted to the minimum required permissions, which are:
|
||||||
# * Metadata - read
|
# * Metadata - read
|
||||||
# * Contents - read/write
|
# * Contents - read/write
|
||||||
# (https://github.com/settings/personal-access-tokens/new)
|
# (https://github.com/settings/personal-access-tokens/new)
|
||||||
|
|
|
@ -1117,8 +1117,7 @@ def push_binary_transparency(git_repo_path, git_remote):
|
||||||
|
|
||||||
|
|
||||||
def find_release_infos(index_v2_path, repo_dir, package_names):
|
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
|
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
|
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():
|
for version in package.get('versions', {}).values():
|
||||||
if package_name not in release_infos:
|
if package_name not in release_infos:
|
||||||
release_infos[package_name] = {}
|
release_infos[package_name] = {}
|
||||||
ver_name = version['manifest']['versionName']
|
version_name = version['manifest']['versionName']
|
||||||
apk_path = version['file']['name']
|
version_path = repo_dir / version['file']['name'].lstrip("/")
|
||||||
if apk_path.startswith('/'):
|
files = [version_path]
|
||||||
apk_path = apk_path[1:]
|
asc_path = pathlib.Path(str(version_path) + '.asc')
|
||||||
apk_path = repo_dir / apk_path
|
|
||||||
files = [apk_path]
|
|
||||||
asc_path = pathlib.Path(str(apk_path) + '.asc')
|
|
||||||
if asc_path.is_file():
|
if asc_path.is_file():
|
||||||
files.append(asc_path)
|
files.append(asc_path)
|
||||||
idsig_path = pathlib.Path(str(apk_path) + '.idsig')
|
sig_path = pathlib.Path(str(version_path) + '.sig')
|
||||||
if idsig_path.is_file():
|
if sig_path.is_file():
|
||||||
files.append(idsig_path)
|
files.append(sig_path)
|
||||||
release_infos[package_name][ver_name] = {
|
release_infos[package_name][version_name] = {
|
||||||
'files': files,
|
'files': files,
|
||||||
'whatsNew': version.get('whatsNew', {}).get("en-US"),
|
'whatsNew': version.get('whatsNew', {}).get("en-US"),
|
||||||
'hasReleaseChannels': len(version.get('releaseChannels', [])) > 0,
|
'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', []):
|
for package_name in repo_conf.get('packages', []):
|
||||||
package_names.append(package_name)
|
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:
|
for repo_conf in gh_config:
|
||||||
upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token)
|
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):
|
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:
|
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
|
return
|
||||||
token = repo_conf.get('token') or global_gh_token
|
token = repo_conf.get("token") or global_gh_token
|
||||||
if not 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
|
return
|
||||||
packages = repo_conf.get('packages', [])
|
packages = repo_conf.get("packages", [])
|
||||||
if not 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
|
return
|
||||||
|
|
||||||
# lookup all versionNames (git tags) for all packages available in the
|
# 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
|
# Making sure we're not uploading this version when releaseChannels
|
||||||
# is set. (releaseChannels usually mean it's e.g. an alpha or beta
|
# is set. (releaseChannels usually mean it's e.g. an alpha or beta
|
||||||
# version)
|
# 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
|
# collect files associated with this github release
|
||||||
files = []
|
files = []
|
||||||
for package in packages:
|
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
|
# always use the whatsNew text from the first app listed in
|
||||||
# config.qml github_releases.packages
|
# 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:
|
if 'release_notes_prepend' in repo_conf:
|
||||||
text = repo_conf['release_notes_prepend'] + "\n\n" + text
|
text = repo_conf['release_notes_prepend'] + "\n\n" + text
|
||||||
# create new release on github and upload all associated files
|
# create new release on github and upload all associated files
|
||||||
|
@ -1346,7 +1368,9 @@ def main():
|
||||||
if config.get('virustotal_apikey'):
|
if config.get('virustotal_apikey'):
|
||||||
upload_to_virustotal(repo_section, config.get('virustotal_apikey'))
|
upload_to_virustotal(repo_section, config.get('virustotal_apikey'))
|
||||||
if config.get('github_releases'):
|
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')
|
binary_transparency_remote = config.get('binary_transparency_remote')
|
||||||
if binary_transparency_remote:
|
if binary_transparency_remote:
|
||||||
|
|
|
@ -1211,7 +1211,6 @@ class DeployTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class GitHubReleasesTest(unittest.TestCase):
|
class GitHubReleasesTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_find_release_infos(self):
|
def test_find_release_infos(self):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
|
@ -1331,7 +1330,6 @@ class GitHubReleasesTest(unittest.TestCase):
|
||||||
), unittest.mock.patch(
|
), unittest.mock.patch(
|
||||||
"fdroidserver.deploy.upload_to_github_releases_repo", urr_mock
|
"fdroidserver.deploy.upload_to_github_releases_repo", urr_mock
|
||||||
), tempfile.TemporaryDirectory() as tmpdir:
|
), tempfile.TemporaryDirectory() as tmpdir:
|
||||||
|
|
||||||
with open(Path(tmpdir) / "index-v2.json", "w") as f:
|
with open(Path(tmpdir) / "index-v2.json", "w") as f:
|
||||||
f.write("")
|
f.write("")
|
||||||
|
|
||||||
|
@ -1370,7 +1368,6 @@ class GitHubReleasesTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.repo_conf = {
|
self.repo_conf = {
|
||||||
"repo": "example/app",
|
"repo": "example/app",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue