From 2a25dbb22fdf64644d2ca96a72c1ebe7f2e35375 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Thu, 31 Oct 2024 16:28:46 +0100 Subject: [PATCH] Bintray is deprecated --- .github/workflows/cd.yml | 2 - scripts/upload_libkiwix_android_to_bintray.py | 83 ------------------- 2 files changed, 85 deletions(-) delete mode 100755 scripts/upload_libkiwix_android_to_bintray.py diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4380b55..9d4068f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -168,8 +168,6 @@ jobs: kiwix-build/.github/scripts/build_release_nightly.py env: COMPILE_CONFIG: ${{matrix.config}} - BINTRAY_USER: kiwix - BINTRAY_PASS: ${{secrets.bintray_pass}} - name: Upload failure logs if: failure() run: $HOME/kiwix-build/.github/scripts/upload_failure_logs.py diff --git a/scripts/upload_libkiwix_android_to_bintray.py b/scripts/upload_libkiwix_android_to_bintray.py deleted file mode 100755 index 43bd6e7..0000000 --- a/scripts/upload_libkiwix_android_to_bintray.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python3 - -import os, sys -import json -import requests - -bintray_auth = (os.environ['BINTRAY_USER'], os.environ['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(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)) -