diff --git a/.github/scripts/build_definition.py b/.github/scripts/build_definition.py index b00ee09..880de81 100644 --- a/.github/scripts/build_definition.py +++ b/.github/scripts/build_definition.py @@ -15,48 +15,49 @@ import csv, io, re # 'D' letter means we trigger the docker forkflow to build the docker image. # If a cell contains several letters, all are done. BUILD_DEF = """ - | OS_NAME | PLATFORM_TARGET | libzim | libkiwix | zim-tools | kiwix-tools | kiwix-desktop | - ============================================================================================== + | OS_NAME | PLATFORM_TARGET | libzim | libkiwix | zim-tools | kiwix-tools | kiwix-desktop | platform_name | + ===================================================================================================================== # Bionic is a special case as we need to compile libzim on old arch for python - | bionic | | BP | | | | | - ---------------------------------------------------------------------------------------------- + | bionic | native_mixed | BP | | | | | linux-x86_64-bionic | + | bionic | aarch64_mixed | BP | | | | | linux-aarch64-bionic | + -------------------------------------------------------------------------------------------------------------------- # Osx builds, build binaries on native_dyn and native_static. On anyother things, build only the libraries - | macos | native_dyn | d | d | dB | B | | - | macos | native_static | | | BP | BP | | - | macos | native_mixed | BP | BP | | | | - | macos | iOS_arm64 | dB | B | | | | - | macos | iOS_x86_64 | dB | B | | | | - | macos | iOS_Mac_ABI | B | B | | | | - | macos | macOS_arm64_static | | | | | | - | macos | macOS_arm64_mixed | BP | BP | | | | - | macos | macOS_x86_64 | B | B | | | | + | macos | native_dyn | d | d | dB | B | | | + | macos | native_static | | | BP | BP | | macos-x86_64 | + | macos | native_mixed | BP | BP | | | | macos-x86_64 | + | macos | iOS_arm64 | dB | B | | | | | + | macos | iOS_x86_64 | dB | B | | | | | + | macos | iOS_Mac_ABI | B | B | | | | | + | macos | macOS_arm64_static | | | | | | | + | macos | macOS_arm64_mixed | BP | BP | | | | macos-arm64 | + | macos | macOS_x86_64 | B | B | | | | | ---------------------------------------------------------------------------------------------- - | | flatpak | | | | | BP | - | | native_static | d | d | dBPSD | dBPSD | | - | | native_dyn | d | d | dB | dB | BPS | - | | native_mixed | BPS | BPS | | | | + | | flatpak | | | | | BP | | + | | native_static | d | d | dBPSD | dBPSD | | linux-x86_64 | + | | native_dyn | d | d | dB | dB | BPS | | + | | native_mixed | BPS | BPS | | | | linux-x86_64 | # libzim CI is building alpine_dyn but not us - | | android_arm | dBP | dBP | | | | - | | android_arm64 | dBP | dBP | | | | - | | android_x86 | BP | BP | | | | - | | android_x86_64 | BP | BP | | | | - | | armv6_static | | | BP | BP | | - | | armv6_dyn | | | B | B | | - | | armv6_mixed | BP | | | | | - | | armv8_static | | | BP | BP | | - | | armv8_dyn | | | B | B | | - | | armv8_mixed | BP | | | | | - | | aarch64_static | | | BP | BP | | - | | aarch64_dyn | d | | B | B | | - | | aarch64_mixed | BP | | | | | - | | aarch64_musl_static| | | BP | BP | | - | | aarch64_musl_dyn | d | | B | B | | - | | aarch64_musl_mixed | BP | | | | | - | | win32_static | d | dB | dBP | dBP | | - | | win32_dyn | d | dB | dB | dB | | - | | i586_static | | | BP | BP | | - | | i586_dyn | | | B | B | | - | | wasm | dBP | | | | | + | | android_arm | dBP | dBP | | | | android-arm | + | | android_arm64 | dBP | dBP | | | | android-arm64 | + | | android_x86 | BP | BP | | | | android-x86 | + | | android_x86_64 | BP | BP | | | | android-x86_64 | + | | armv6_static | | | BP | BP | | linux-armv6 | + | | armv6_dyn | | | B | B | | | + | | armv6_mixed | BP | | | | | linux-armv6 | + | | armv8_static | | | BP | BP | | linux-armv8 | + | | armv8_dyn | | | B | B | | | + | | armv8_mixed | BP | | | | | linux-armv8 | + | | aarch64_static | | | BP | BP | | linux-aarch64 | + | | aarch64_dyn | d | | B | B | | | + | | aarch64_mixed | BP | | | | | linux-aarch64 | + | | aarch64_musl_static| | | BP | BP | | linux-aarch64-musl | + | | aarch64_musl_dyn | d | | B | B | | | + | | aarch64_musl_mixed | BP | | | | | linux-aarch64-musl | + | | win32_static | d | dB | dBP | dBP | | win-i686 | + | | win32_dyn | d | dB | dB | dB | | | + | | i586_static | | | BP | BP | | linux-i586 | + | | i586_dyn | | | B | B | | | + | | wasm | dBP | | | | | wasm-emscripten | """ @@ -128,3 +129,16 @@ def select_build_targets(criteria): return build_order raise "No definition match with current context." + +def get_platform_name(): + from common import PLATFORM_TARGET, OS_NAME + + context = Context(PLATFORM_TARGET=PLATFORM_TARGET, OS_NAME=OS_NAME) + + reader = csv.DictReader(strip_array(BUILD_DEF), dialect=TableDialect()) + for row in reader: + if context.match(row): + name = row["platform_name"] + return name or None + + raise "No definition match with current context." diff --git a/.github/scripts/common.py b/.github/scripts/common.py index a9192df..83561f3 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -10,12 +10,16 @@ import shutil import requests +from build_definition import get_platform_name + from kiwixbuild.versions import ( main_project_versions, release_versions, base_deps_versions, ) + + PLATFORM_TARGET = _environ["PLATFORM_TARGET"] OS_NAME = _environ["OS_NAME"] HOME = Path(os.path.expanduser("~")) @@ -36,31 +40,6 @@ if not MAKE_RELEASE and _ref != "main": else: DEV_BRANCH = None -RELEASE_OS_NAME = "macos" if OS_NAME == "macos" else "linux" -EXTRA_NAME = "-bionic" if OS_NAME == "bionic" else "" - -PLATFORM_TO_RELEASE = { - "native_mixed": "{os}-x86_64{extra}".format(os=RELEASE_OS_NAME, extra=EXTRA_NAME), - "native_static": "{os}-x86_64".format(os=RELEASE_OS_NAME), - "win32_static": "win-i686", - "armv6_static": "{os}-armv6".format(os=RELEASE_OS_NAME), - "armv6_mixed": "{os}-armv6".format(os=RELEASE_OS_NAME), - "armv8_static": "{os}-armv8".format(os=RELEASE_OS_NAME), - "armv8_mixed": "{os}-armv8".format(os=RELEASE_OS_NAME), - "aarch64_static": "{os}-aarch64".format(os=RELEASE_OS_NAME), - "aarch64_mixed": "{os}-aarch64{extra}".format(os=RELEASE_OS_NAME, extra=EXTRA_NAME), - "aarch64_musl_static": "{os}-aarch64-musl".format(os=RELEASE_OS_NAME), - "aarch64_musl_mixed": "{os}-aarch64-musl".format(os=RELEASE_OS_NAME), - "i586_static": "{os}-i586".format(os=RELEASE_OS_NAME), - "macOS_arm64_static": "{os}-arm64".format(os=RELEASE_OS_NAME), - "macOS_arm64_mixed": "{os}-arm64".format(os=RELEASE_OS_NAME), - "android_arm": "android-arm", - "android_arm64": "android-arm64", - "android_x86": "android-x86", - "android_x86_64": "android-x86_64", - "wasm": "wasm-emscripten", -} - FLATPAK_HTTP_GIT_REMOTE = "https://github.com/flathub/org.kiwix.desktop.git" FLATPAK_GIT_REMOTE = "git@github.com:flathub/org.kiwix.desktop.git" @@ -351,10 +330,8 @@ def get_postfix(project): def make_archive(project, make_release): - try: - platform = PLATFORM_TO_RELEASE[PLATFORM_TARGET] - except KeyError: - # We don't know how to name the release. + platform_name = get_platform_name() + if not platform_name: return None try: @@ -368,12 +345,12 @@ def make_archive(project, make_release): else: postfix = DATE - archive_name = "{}_{}-{}".format(project, platform, postfix) + archive_name = "{}_{}-{}".format(project, platform_name, postfix) files_to_archive = [] for export_file in export_files: files_to_archive.extend(base_dir.glob(export_file)) - if platform == "win-i686": + if platform_name == "win-i686": open_archive = lambda a: zipfile.ZipFile( str(a), "w", compression=zipfile.ZIP_DEFLATED )