diff --git a/.github/scripts/build_release_nightly.py b/.github/scripts/build_release_nightly.py index 61277e1..97d679c 100755 --- a/.github/scripts/build_release_nightly.py +++ b/.github/scripts/build_release_nightly.py @@ -1,14 +1,11 @@ #!/usr/bin/env python3 import os -import json -import shutil from common import ( run_kiwix_build, main_project_versions, release_versions, - get_postfix, make_archive, create_desktop_image, update_flathub_git, @@ -24,8 +21,6 @@ from common import ( notarize_macos_build, ) -from upload_to_bintray import upload_from_json - if os.environ.get('GITHUB_EVENT_NAME') == 'schedule': RELEASE = False @@ -106,28 +101,3 @@ if RELEASE: # Publish flathub if PLATFORM_TARGET == "flatpak" and "kiwix-desktop" in TARGETS: 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) diff --git a/.github/scripts/upload_to_bintray.py b/.github/scripts/upload_to_bintray.py deleted file mode 100755 index c2fc8c2..0000000 --- a/.github/scripts/upload_to_bintray.py +++ /dev/null @@ -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)) -