Merge pull request #531 from kiwix/release_android_fix
This commit is contained in:
commit
17c8c92dba
|
@ -1,14 +1,11 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
from common import (
|
from common import (
|
||||||
run_kiwix_build,
|
run_kiwix_build,
|
||||||
main_project_versions,
|
main_project_versions,
|
||||||
release_versions,
|
release_versions,
|
||||||
get_postfix,
|
|
||||||
make_archive,
|
make_archive,
|
||||||
create_desktop_image,
|
create_desktop_image,
|
||||||
update_flathub_git,
|
update_flathub_git,
|
||||||
|
@ -24,15 +21,13 @@ from common import (
|
||||||
notarize_macos_build,
|
notarize_macos_build,
|
||||||
)
|
)
|
||||||
|
|
||||||
from upload_to_bintray import upload_from_json
|
|
||||||
|
|
||||||
|
|
||||||
if os.environ.get('GITHUB_EVENT_NAME') == 'schedule':
|
if os.environ.get('GITHUB_EVENT_NAME') == 'schedule':
|
||||||
RELEASE = False
|
RELEASE = False
|
||||||
else:
|
else:
|
||||||
RELEASE = True
|
RELEASE = True
|
||||||
|
|
||||||
if PLATFORM_TARGET == "android":
|
if PLATFORM_TARGET.startswith("android_"):
|
||||||
TARGETS = ("libkiwix",)
|
TARGETS = ("libkiwix",)
|
||||||
elif PLATFORM_TARGET.startswith("iOS"):
|
elif PLATFORM_TARGET.startswith("iOS"):
|
||||||
TARGETS = ("libzim", "libkiwix")
|
TARGETS = ("libzim", "libkiwix")
|
||||||
|
@ -59,12 +54,6 @@ if RELEASE:
|
||||||
return release_versions.get(project) is not None
|
return release_versions.get(project) is not None
|
||||||
TARGETS = tuple(filter(release_filter, TARGETS))
|
TARGETS = tuple(filter(release_filter, TARGETS))
|
||||||
|
|
||||||
if RELEASE and PLATFORM_TARGET == "android":
|
|
||||||
# libkiwix need to know the extrapostfix version to correctly generate the pom.xml file.
|
|
||||||
extra_postfix = release_versions.get('libkiwix')
|
|
||||||
if extra_postfix:
|
|
||||||
os.environ['KIWIXLIB_BUILDVERSION'] = str(extra_postfix)
|
|
||||||
|
|
||||||
for target in TARGETS:
|
for target in TARGETS:
|
||||||
run_kiwix_build(target, platform=PLATFORM_TARGET, make_release=RELEASE)
|
run_kiwix_build(target, platform=PLATFORM_TARGET, make_release=RELEASE)
|
||||||
if target == "kiwix-desktop":
|
if target == "kiwix-desktop":
|
||||||
|
@ -106,28 +95,3 @@ if RELEASE:
|
||||||
# Publish flathub
|
# Publish flathub
|
||||||
if PLATFORM_TARGET == "flatpak" and "kiwix-desktop" in TARGETS:
|
if PLATFORM_TARGET == "flatpak" and "kiwix-desktop" in TARGETS:
|
||||||
update_flathub_git()
|
update_flathub_git()
|
||||||
|
|
||||||
if PLATFORM_TARGET == "android" and "libkiwix" in TARGETS:
|
|
||||||
postfix = get_postfix("libkiwix")
|
|
||||||
basename = "kiwixlib-{}".format(postfix)
|
|
||||||
|
|
||||||
output_release_dir = (
|
|
||||||
HOME / "BUILD_android" / "libkiwix-app" / "kiwixLibAndroid" / "build"
|
|
||||||
)
|
|
||||||
shutil.copy(
|
|
||||||
str(output_release_dir / "outputs" / "aar" / "kiwixLibAndroid-release.aar"),
|
|
||||||
str(TMP_DIR / (basename + ".aar")),
|
|
||||||
)
|
|
||||||
shutil.copy(
|
|
||||||
str(output_release_dir / "pom.xml"), str(TMP_DIR / (basename + ".pom"))
|
|
||||||
)
|
|
||||||
|
|
||||||
json_filename = "{}_bintray_info.json".format(basename)
|
|
||||||
data = {
|
|
||||||
"version": postfix,
|
|
||||||
"files": [basename + ext for ext in (".aar", ".pom")],
|
|
||||||
}
|
|
||||||
with open(str(TMP_DIR / json_filename), "w") as f:
|
|
||||||
json.dump(data, f)
|
|
||||||
|
|
||||||
upload_from_json(TMP_DIR / json_filename)
|
|
||||||
|
|
|
@ -145,11 +145,6 @@ def run_kiwix_build(
|
||||||
command.append("--hide-progress")
|
command.append("--hide-progress")
|
||||||
command.append("--fast-clone")
|
command.append("--fast-clone")
|
||||||
command.append("--assume-packages-installed")
|
command.append("--assume-packages-installed")
|
||||||
if platform == "android":
|
|
||||||
command.extend(["--target-platform", "android"])
|
|
||||||
for arch in ("arm", "arm64", "x86", "x86_64"):
|
|
||||||
command.extend(["--android-arch", arch])
|
|
||||||
else:
|
|
||||||
command.extend(["--target-platform", platform])
|
command.extend(["--target-platform", platform])
|
||||||
if build_deps_only:
|
if build_deps_only:
|
||||||
command.append("--build-deps-only")
|
command.append("--build-deps-only")
|
||||||
|
@ -245,11 +240,9 @@ def make_deps_archive(target=None, name=None, full=False):
|
||||||
files_to_archive += HOME.glob("BUILD_*/LOGS")
|
files_to_archive += HOME.glob("BUILD_*/LOGS")
|
||||||
if PLATFORM_TARGET == "native_mixed":
|
if PLATFORM_TARGET == "native_mixed":
|
||||||
files_to_archive += [HOME / "BUILD_native_static" / "INSTALL"]
|
files_to_archive += [HOME / "BUILD_native_static" / "INSTALL"]
|
||||||
if PLATFORM_TARGET.startswith("android"):
|
if PLATFORM_TARGET.startswith("android_"):
|
||||||
files_to_archive.append(HOME / "BUILD_neutral" / "INSTALL")
|
files_to_archive.append(HOME / "BUILD_neutral" / "INSTALL")
|
||||||
if PLATFORM_TARGET == "android":
|
base_dir = HOME / "BUILD_{}".format(PLATFORM_TARGET)
|
||||||
for arch in ("arm", "arm64", "x86", "x86_64"):
|
|
||||||
base_dir = HOME / "BUILD_android_{}".format(arch)
|
|
||||||
files_to_archive.append(base_dir / "INSTALL")
|
files_to_archive.append(base_dir / "INSTALL")
|
||||||
if (base_dir / "meson_cross_file.txt").exists():
|
if (base_dir / "meson_cross_file.txt").exists():
|
||||||
files_to_archive.append(base_dir / "meson_cross_file.txt")
|
files_to_archive.append(base_dir / "meson_cross_file.txt")
|
||||||
|
|
|
@ -48,25 +48,10 @@ try:
|
||||||
f.extractall(str(HOME))
|
f.extractall(str(HOME))
|
||||||
os.remove(str(local_filename))
|
os.remove(str(local_filename))
|
||||||
except URLError:
|
except URLError:
|
||||||
print_message("Cannot get archive. Build dependencies")
|
if PLATFORM_TARGET == "flatpak":
|
||||||
if PLATFORM_TARGET == "android":
|
|
||||||
for arch in ("arm", "arm64", "x86", "x86_64"):
|
|
||||||
archive_name = ARCHIVE_NAME_TEMPLATE.format(
|
|
||||||
os=OS_NAME,
|
|
||||||
platform="android_{}".format(arch),
|
|
||||||
version=base_deps_meta_version,
|
|
||||||
)
|
|
||||||
print_message("Getting archive {}", archive_name)
|
|
||||||
try:
|
|
||||||
local_filename = download_base_archive(archive_name)
|
|
||||||
with tarfile.open(local_filename) as f:
|
|
||||||
f.extractall(str(HOME))
|
|
||||||
os.remove(str(local_filename))
|
|
||||||
except URLError:
|
|
||||||
pass
|
|
||||||
elif PLATFORM_TARGET == "flatpak":
|
|
||||||
print_message("Cannot get archive. Move on")
|
print_message("Cannot get archive. Move on")
|
||||||
else:
|
else:
|
||||||
|
print_message("Cannot get archive. Build dependencies")
|
||||||
run_kiwix_build("alldependencies", platform=PLATFORM_TARGET)
|
run_kiwix_build("alldependencies", platform=PLATFORM_TARGET)
|
||||||
archive_file = make_deps_archive(name=base_dep_archive_name, full=True)
|
archive_file = make_deps_archive(name=base_dep_archive_name, full=True)
|
||||||
upload(archive_file, "ci@tmp.kiwix.org:30022", "/data/tmp/ci")
|
upload(archive_file, "ci@tmp.kiwix.org:30022", "/data/tmp/ci")
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import os, sys
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
|
|
||||||
bintray_auth = (os.environ.get('BINTRAY_USER'), os.environ.get('BINTRAY_PASS'))
|
|
||||||
|
|
||||||
def create_version(version):
|
|
||||||
url = "https://api.bintray.com/packages/kiwix/kiwix/kiwixlib/versions"
|
|
||||||
payload = {
|
|
||||||
'name': version,
|
|
||||||
'desc': 'Release of libkiwix'
|
|
||||||
}
|
|
||||||
headers = {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
|
|
||||||
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=bintray_auth)
|
|
||||||
rcode = r.status_code
|
|
||||||
|
|
||||||
if rcode == 409:
|
|
||||||
print("Bintray version %s already exists, skipping." % version)
|
|
||||||
return True
|
|
||||||
|
|
||||||
rcode_family = rcode // 100
|
|
||||||
if rcode_family in (2, 3):
|
|
||||||
print("Bintray Version created!")
|
|
||||||
return True
|
|
||||||
|
|
||||||
print("ERROR : Bintray API response {}".format(rcode))
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def upload(version, filepath, artefact):
|
|
||||||
url_template = "https://api.bintray.com/content/kiwix/kiwix/kiwixlib/{version}/org/kiwix/kiwixlib/kiwixlib/{version}/{artefact}"
|
|
||||||
parameters = {
|
|
||||||
'publish': 1,
|
|
||||||
'override': 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Upload the main artefact
|
|
||||||
url = url_template.format(version=version, artefact=artefact)
|
|
||||||
with open(filepath, 'rb') as f:
|
|
||||||
r = requests.put(url, data=f, auth=bintray_auth, params=parameters)
|
|
||||||
|
|
||||||
rcode = r.status_code
|
|
||||||
rcode_family = rcode // 100
|
|
||||||
if rcode_family not in (2, 3):
|
|
||||||
print("ERROR: Fail to upload artefact")
|
|
||||||
print(r.text)
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def upload_from_json(json_path):
|
|
||||||
basedir = os.path.dirname(str(json_path))
|
|
||||||
with open(str(json_path)) as f:
|
|
||||||
options = json.load(f)
|
|
||||||
|
|
||||||
if not create_version(options['version']):
|
|
||||||
raise RuntimeError("Cannot create version")
|
|
||||||
|
|
||||||
for file_ in options['files']:
|
|
||||||
path = os.path.join(basedir, file_)
|
|
||||||
if not upload(options['version'], path, file_):
|
|
||||||
raise RuntimeError("Cannot upload file {}".format(file_))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
try:
|
|
||||||
info_file = sys.argv[1]
|
|
||||||
except IndexError:
|
|
||||||
print("Usage {} infofile".format(sys.argv[0]))
|
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
print("Use info file {}".format(info_file))
|
|
||||||
try:
|
|
||||||
upload_from_json(info_file)
|
|
||||||
except RuntimeError as e:
|
|
||||||
sys.exit(str(e))
|
|
||||||
|
|
|
@ -43,7 +43,10 @@ jobs:
|
||||||
- armhf_static
|
- armhf_static
|
||||||
- win32_static
|
- win32_static
|
||||||
- i586_static
|
- i586_static
|
||||||
- android
|
- android_arm
|
||||||
|
- android_arm64
|
||||||
|
- android_x86
|
||||||
|
- android_x86_64
|
||||||
include:
|
include:
|
||||||
- target: native_static
|
- target: native_static
|
||||||
image_variant: bionic
|
image_variant: bionic
|
||||||
|
@ -66,7 +69,16 @@ jobs:
|
||||||
- target: i586_static
|
- target: i586_static
|
||||||
image_variant: bionic
|
image_variant: bionic
|
||||||
lib_postfix: '/x86_64-linux-gnu'
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
- target: android
|
- target: android_arm
|
||||||
|
image_variant: bionic
|
||||||
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
|
- target: android_arm64
|
||||||
|
image_variant: bionic
|
||||||
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
|
- target: android_x86
|
||||||
|
image_variant: bionic
|
||||||
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
|
- target: android_x86_64
|
||||||
image_variant: bionic
|
image_variant: bionic
|
||||||
lib_postfix: '/x86_64-linux-gnu'
|
lib_postfix: '/x86_64-linux-gnu'
|
||||||
env:
|
env:
|
||||||
|
|
Loading…
Reference in New Issue