From a44531bb8a6bc0f0ed129465866d6e15dd35c764 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 16 Nov 2022 11:24:17 +0100 Subject: [PATCH] Upload generated packages on `tmp/ci` when building on branches. We need to be able to test our generated artefacts before we merge the branches. --- .github/scripts/build_projects.py | 8 ++++++-- .github/scripts/common.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/scripts/build_projects.py b/.github/scripts/build_projects.py index bbf0e20..d30723c 100755 --- a/.github/scripts/build_projects.py +++ b/.github/scripts/build_projects.py @@ -6,9 +6,11 @@ from common import ( make_archive, create_desktop_image, fix_macos_rpath, + upload_archive, OS_NAME, PLATFORM_TARGET, DESKTOP, + DEV_BRANCH, ) if (PLATFORM_TARGET.startswith("android_") @@ -40,8 +42,10 @@ else: for target in TARGETS: run_kiwix_build(target, platform=PLATFORM_TARGET) if target == "kiwix-desktop": - create_desktop_image(make_release=False) + archive = create_desktop_image(make_release=False) else: if PLATFORM_TARGET == "native_mixed" and OS_NAME == "osx": fix_macos_rpath(target) - make_archive(target, make_release=False) + archive = make_archive(target, make_release=False) + if archive: + upload_archive(archive, target, make_release=False, dev_branch=DEV_BRANCH) diff --git a/.github/scripts/common.py b/.github/scripts/common.py index c31c8b6..67b8d46 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -39,6 +39,11 @@ _ref = _environ.get("GITHUB_REF", "").split("/")[-1] MAKE_RELEASE = re.fullmatch(r"r_[0-9]+", _ref) is not None MAKE_RELEASE = MAKE_RELEASE and (_environ.get('GITHUB_EVENT_NAME') != 'schedule') +if not MAKE_RELEASE and _ref != "master": + DEV_BRANCH = _ref +else: + DEV_BRANCH = None + RELEASE_OS_NAME = "macos" if OS_NAME == "osx" else "linux" PLATFORM_TO_RELEASE = { @@ -227,7 +232,7 @@ def upload(file_to_upload, host, dest_path): subprocess.check_call(command) -def upload_archive(archive, project, make_release): +def upload_archive(archive, project, make_release, dev_branch=None): if not archive.exists(): print_message("No archive {} to upload!", archive) return @@ -244,9 +249,12 @@ def upload_archive(archive, project, make_release): else: dest_path = dest_path + "nightly/" + DATE - # Make the archive read only. This way, scp will preserve rights. - # If somehow we try to upload twice the same archive, scp will fails. - archive.chmod(0o444) + if dev_branch: + dest_path = "/data/tmp/ci/" + dev_branch + else: + # Make the archive read only. This way, scp will preserve rights. + # If somehow we try to upload twice the same archive, scp will fails. + archive.chmod(0o444) upload(archive, host, dest_path)